ShelfPlayer icon indicating copy to clipboard operation
ShelfPlayer copied to clipboard

Bug: Latest Version of Shelfplayer and ABS, Crashes Repeatedly (Related to Offline)

Open errantmind opened this issue 1 month ago • 3 comments

iPhone 13 mini iOS: 18.6.2 ABS: v2.30.0 ShelfPlayer: 3.1.2 Database: 2.0.0 ShelfPlayerUpdated

My ABS server is only accessible on the local network. When opening the app when not connected to the local wifi, the app sometimes loads in offline mode the very first attempt, but subsequent attempts (after force closing) crash the app immediately, nothing even visibly displays. This happens with: wifi disabled, airplane mode on and off, and wifi on but not connected.

I've attempted 20 times in a row where I open the app and it insta-crashes. It doesn't exist at this point to force close it. If I reconnect to the local wifi the app loads successfully. If I then disconnect the wifi, force close it, and re-open it fresh, it may load offline once. If I then force close the app and re-open it it starts the repeated insta-crashes.

errantmind avatar Nov 13 '25 23:11 errantmind

Guess:

A race condition related to offline handling in Satellite.swift. I looked at this for a while and it seems, even though you annotate the class with @MainActor, that doesn't mean everything inside will run on the main actor in all situations, specifically tasks / closures (a problem when they mutate main actor state).

The relevant example:

In Satellite.setupObservers() -> changeOfflineMode handler: Might mutate UIKit and @MainActor state off-main which might create a race condition if handler is called too early in the startup process.

Perhaps this can be fixed by moving UIAppearance changes and isOffline assignment into Task { @MainActor in … }.

There's another Task { ... } in the same class that might need the same solution.

errantmind avatar Nov 14 '25 01:11 errantmind

Not quite: The subscriber is a wrapper around the NotificationCenter-API, and while it is a bit wonky, it should be able to inherit the actor context: https://git.sr.ht/~rasmuslos/RFKit/tree/main/item/Sources/RFNotifications/RFNotification.swift#L230 The Task also inherits the context, you would have to use Task.detached to dispatch something to an arbitrary queue.

Although i agree, something there might not work as intended, the codebase runs on Swift 6 and i want to upgrade to Swift 6.2, which has some concurrency improvements, but that is a lot of work, that i just did for Swift 6...

Could you please share the Crash logs?

rasmuslos avatar Nov 14 '25 10:11 rasmuslos

Ah alright. I thought the handlers would potentially run off-main but I'm not very knowledgeable about Swift so I'll leave it there.

As for logs, I don't have access to the device at the moment (not my phone) and don't have a Mac to transfer them to regardless. Sorry, not much help I know.

errantmind avatar Nov 14 '25 17:11 errantmind