Closed psegalen closed 6 years ago
I just realized that the line in my code causing the crash is not the update of stream.videoSettings
but a reading of it:
let currentBitrate = stream.videoSettings["bitrate"] as! Int
That's odd... I'll save my bitrate in an instance variable to avoid reading it but I'm afraid that updating the value will cause the same crash sooner or later.
It crashes on updating the value too, I have it on my Xcode, it shows a "EXC_BREAKPOINT" at this line: https://github.com/shogo4405/HaishinKit.swift/blob/master/Sources/Net/NetStream.swift#L86
It seems to be a deadlock, following blogpost reports deadlocks being possible when using dispatch_sync
, a friend of mine (@clmntcrl) pointed a possible solution to me, I'll try it.
http://blog.benjamin-encz.de/post/main-queue-vs-main-thread/
@shogo4405 FYI, I've just tested the code I submitted in the PR by streaming for more than an hour from my app (with my adaptive bitrate algorithm) on an iPod Touch. Before this test, the app always crashed at some point during the 10 first minutes of the stream.
My app randomly crashes when using HaishinKit, here is the stack:
It seems to be caused by my adaptive bitrate algorithm based on
rtmpStream.currentFPS
observer. Here is my code of the observer:Should I check something about the thread I'm running on before modifying
rtmpStream.videoSettings
?