emorydunn / StreamDeckPlugin

A library for creating Stream Deck plugins in Swift.
https://emorydunn.github.io/StreamDeckPlugin/
MIT License
50 stars 7 forks source link

[NSConcreteTask waitUntilExit] Error #28

Closed SENTINELITE closed 4 months ago

SENTINELITE commented 5 months ago

Hey, Emory!

This bug's been haunting me for many, many months. I think it's related to the WebSocket stuff, can you confirm?

I'll add that this was on far older versions of the package, but I'm still seeing them up-to the more recent #21's GlobalSettings branch. I haven't isolated it to the most recent main branch, but I assume it's still there?

Some people say it occurs when the computer wakes up from a sleep cycle, network changes (VPNs/WIFI, etc).

It's extremely hard to reproduce. I've (personally_ only had it a handful of times, since I picked up this project.

I'm also unable to attach to the process via Xcode's debugger tools.

Lastly, is there anyway to get the StreamDeckPlugin's osLogs to filter through Elgato's logger? (logMessage), so end-user debugging is easier?

From a support ticket:

It could be related to changing WiFi networks. Every day I go between office and home. Maybe this is invalidating the client/server socket addresses due to routing/gateway changes and they need to be closed and restarted. Basically if you can get any socket logging enabled this will probably help.

https://github.com/SENTINELITE/StreamDeck-Shortcuts/issues/19

emorydunn commented 5 months ago

I don't think I've seen anything like that with my plugins. I'll ask around with my users to see if they've noticed anything. I'm not directly calling NSConcreteTask (I don't think), so that would indicate a deeper issue in theWebSocket API, perhaps.

As for the logging, good question. I probably could manually log more events through the Elgato logger, although if the issue is with the WebSocket the plugin would be shouting into the void with logMessage. If nothing else I can look for any instances I'm calling log.debug, in which case the message isn't preserved, and replace it with log.log.

I've build a log collection mechanism for my GUI apps, so I can probably build a log collection plugin action into the library. Then the plugin developer could include that in the manifest for a nice single-button action to save the logs to Downloads. Probably only useful if you're sending betas outside of the Elgato store, but if folks are creating issues on GitHub they can probably manage.

SENTINELITE commented 5 months ago

Hm. I'm not really sure what that means? Should I file a Radar with Apple or?

I'm seeing the following event's failing, when a crash is happening.

3   StreamDeck-Shortcuts_Alt               0x10469c648 PluginCommunication.parseEvent(event:context:data:) + 33184 (PluginCommunication.swift:419)
4   StreamDeck-Shortcuts_Alt               0x10469299c PluginCommunication.parseMessage(_:) + 936 (PluginCommunication.swift:168)
5   StreamDeck-Shortcuts_Alt               0x104691a6c closure #1 in PluginCommunication.monitorSocket() + 692 (PluginCommunication.swift:130)

As per the logs, that'd be a welcome addition!

emorydunn commented 5 months ago

I'd hold off on the Radars, the odds of that's it's an error on my end, compared to Apple, are fairly high.

Those logs are super interesting. Line 419 is where device connection events are handled, which certainly tracks with the issue. However, if an error is thrown there it should be handled further up the chain in a non-crashing way. I'll have to give your repo a clone and see if anything jumps out.

No promises on the timeline for any logging improvements, I should probably merge in all of the pending changes first πŸ˜…

SENTINELITE commented 5 months ago

Got it. V1 has some large bugs, so I'd give this version a clone. It should be (mostly) smooth. https://github.com/SENTINELITE/StreamDeck-Shortcuts/pull/20/commits/55d0135101a7bf502e550d6aa65428c0dc83b504

No promises on the timeline for any logging improvements, I should probably merge in all of the pending changes first πŸ˜…

Of course. That makes sense! It was just something that stood out to me, that would make the DX a little better!

emorydunn commented 5 months ago

I was looking through the library code, and realized there actually has been a change that may be related to the issue. I switched to using a run loop for keeping the plugin alive. Unfortunately I didn't document why I made the change, but it would be worth updating to see if the issue persists.

SENTINELITE commented 5 months ago

Alright. I've bumped to the latest version & will keep you posted, after I get some feedback.

Thanks, Emory!

SENTINELITE commented 4 months ago

It seems to be that these related changes have fixed those issues! Thanks a lot, Emory!

emorydunn commented 4 months ago

Great to hear that solved the problem. Does this count as fixing a bug in negative time? πŸ˜†

SENTINELITE commented 4 months ago

Hahaha, absolutely! πŸ˜‚