Closed wqz-leo closed 5 years ago
Okay, setup a git repo and I'll take a look.
Unfortunately, it's not easy to replicate the same situation, and I'm not able to share my source code.
Here's what happened in theory:
I'm downloading some videos in my app, download progress is received from URLSession and pass value to Event, then the event emits progress on main thread by wrapping into DispatchQueue.main.async
. On navigating back, I call listener.isListening = false
in deinit
and that's the place where crash happens.
The _stopListening
method of EventListener
should never crash. Your downloadStateListener
is being removed from its event while its isListening
property is still true. If you can find where that's happening, we can track down the real bug.
Side note: You don't need to set downloadStateListener.isListening = false
manually. When your DownloadButton
instance is released, the listener is removed from its event automatically.
Please find the crash in the screenshot above. As mentioned in #57, force unwrapping
_listeners[_targetID]
is causing the crash because there's no value in_listeners
.