Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App crashes on launch on AppleTV hardware, not simulator #153

Open
rdas-ditto opened this issue Sep 10, 2024 · 2 comments
Open

App crashes on launch on AppleTV hardware, not simulator #153

rdas-ditto opened this issue Sep 10, 2024 · 2 comments
Assignees

Comments

@rdas-ditto
Copy link
Contributor

rdas-ditto commented Sep 10, 2024

Checked out main branch, launched on Apple TV 4K A1842 (64GB)

Note: the app works ok in Simulator, this is only on device.

App loads to a black screen, and I see the following error that DittoDirectoriesCreationFailed

If I let it run, the system eventually kills the app, and eventually tells me that the line static var shared = DittoManager() failed. (DittoManager.swift:69)

2024-09-10T17:54:47.672463Z  INFO init_logging:init_tracing{config.service_name="ditto" tracing_format="json" rust_log="trace"}: tracing_config: initializing tracing opentelemetry_enabled=false loki_enabled=false
2024-09-10T17:54:47.672681Z  INFO post_init_logging: ditto_logging: successfully initialized small peer tracing registry
2024-09-10T17:54:47.672694Z  INFO post_init_logging: ditto_logging: installed tracing-log compatibility layer originator=tracing-config
*** Terminating app due to uncaught exception 'DittoDirectoriesCreationFailed', reason: 'The necessary directories failed to be created.'
*** First throw call stack:
(0x181768ffc 0x180c36d4c 0x1084d9f4c 0x1084dc614 0x105d2f1c0 0x105d30340 0x105d2e778 0x104f318e8 0x104f30ea4 0x104f30d60 0x105afdc78 0x105aff5f4 0x104f2df98 0x104f2bef0 0x104f58ca4 0x1d05a7e38 0x104f58b80 0x104f58e68 0x1d136d6f8 0x1d11e9c30 0x1d11e9938 0x1d027ae98 0x1b038f928 0x1b03900ac 0x1b0397e88 0x1b03aed24 0x1d11e97c4 0x1d11e9c04 0x1d11e9938 0x1d027ae98 0x1b038f928 0x1b03900ac 0x1b0397e88 0x1b03aed24 0x1d05a8cd0 0x1d05a8dc8 0x1d027ae98 0x1b038f928 0x1b03900ac 0x1b03974f8 0x1b03aed74 0x1d136c04c 0x1d060f210 0x1d060bef8 0x1d060cab4 0x19ed876c8 0x19f74895c 0x19f748c58 0x19f2bd77c 0x18c33e2f8 0x18c365694 0x18c34ad30 0x18c36540c 0x105afdc78 0x105b01184 0x18c3867c8 0x18c3866d4 0x18c3867fc 0x1816d037c 0x1816d02c4 0x1816cfa88 0x1816ca0c4 0x1816c9988 0x18c4aa9a0 0x19f747430 0x19f74b630 0x1d0c96b14 0x1d0c969ac 0x1d09843ac 0x104f58de0 0x104f58e90 0x180c495f4)
libc++abi: terminating due to uncaught exception of type NSException
@rdas-ditto
Copy link
Contributor Author

So I've narrowed this down to the way that the Ditto object is initialised in the Tools app.

Current (crashes):

// DittoManager.swift

class DittoManager: ObservableObject {
    var ditto: Ditto? = Ditto()
    ...
}

Works correctly:

// DittoManager.swift

class DittoManager: ObservableObject {
    var ditto: Ditto?

    private init() {
        if let cachesURL = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask).first {
            self.ditto = Ditto(persistenceDirectory: cachesURL)
        }
        ...
    }
}

@rdas-ditto
Copy link
Contributor Author

rdas-ditto commented Sep 10, 2024

So we could fix this in the short term with:

// DittoManager.swift

class DittoManager: ObservableObject {
    var ditto: Ditto?

#if os(tvOS)
        let persistenceDirectory: FileManager.SearchPathDirectory = .cachesDirectory
#else
        let persistenceDirectory: FileManager.SearchPathDirectory = .documentDirectory
#endif

    private init() {
        if let cachesURL = FileManager.default.urls(for: persistenceDirectory, in: .userDomainMask).first {
            self.ditto = Ditto(persistenceDirectory: cachesURL)
        }
        ...
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant