pedroSG94/RootEncoder-iOS

Streaming Freeze on iOS 14.X.X and 15.X.X Devices

Closed this issue · 20 comments

Hello,

I'm experiencing an issue with streaming on iOS devices running versions 14.X.X and 15.X.X, (iOS 16 is not tested). The stream freezes after a few seconds, and the console displays a large number of the following logs:

2024-07-10 17:45:24.352996+0300 app[907:59864] [connection] nw_flow_add_read_request [C2.1 XX.XX.XX.XX:XXX ready channel-flow (satisfied (Path is satisfied), viable, interface: en0, ipv4, dns)] already delivered final read, cannot accept read requests

When I comment out the call to videoPacketizer?.createAndSendPacket in RtspSender.swift, the app no longer freezes, but the logs continue to appear. And of course stream is not working.

Notably, this problem does not occur on iOS 17.

Video with demonstration: https://drive.google.com/file/d/1i7_uH4QSSPG_GO2QMQxCMlco2y19Hpu4/view

Hello,

This seems to be a problem related with write debug lines on the console. If you install the app and remove the device from the debuger the app no longer freeze so this maybe a problem related with the xcode debugger. I will try fix it

About this log:

2024-07-10 17:45:24.352996+0300 app[907:59864] [connection] nw_flow_add_read_request [C2.1 XX.XX.XX.XX:XXX ready channel-flow (satisfied (Path is satisfied), viable, interface: en0, ipv4, dns)] already delivered final read, cannot accept read requests

This is maybe related with read data with no data available. Try to check it removing this line:
https://github.com/pedroSG94/RootEncoder-iOS/blob/master/RootEncoder/Sources/RootEncoder/rtsp/rtsp/RtspClient.swift#L171

I observed that the problem occurs specifically when there is no movement in the frame. The stream works fine as long as there is motion, but as soon as the frame becomes static, the stream freezes.

Please see the attached video for a demonstration of the issue: https://drive.google.com/file/d/1u46mljMR-4KXn1d7DbSuUmp2yZAK9q6r/view?usp=sharing

The same behavior occurs even without the debugger.

I see, I tested it but can't reproduce it because I only have devices with iOS 17 (ipad and iphone 11). (Before, I refer to other problem)
Can you tell me the device model?
I will try buy that model

I see, I tested it but can't reproduce it because I only have devices with iOS 17 (ipad and iphone 11). (Before, I refer to other problem) Can you tell me the device model? I will try buy that model

iPhone SE 2016, iPhone 6S 2015

For now, I checked again the first video and pushed a commit that should fix the last logs about AudioCodecInitializationFailed but I'm not sure if this solve others errors.
If the problem persist try to set samplerate to 44100 in prepareAudio method:
https://github.com/pedroSG94/RootEncoder-iOS/blob/master/RootEncoder/Sources/RootEncoder/library/base/CameraBase.swift#L53

For now, I checked again the first video and pushed a commit that should fix the last logs about AudioCodecInitializationFailed but I'm not sure if this solve others errors. If the problem persist try to set samplerate to 44100 in prepareAudio method: https://github.com/pedroSG94/RootEncoder-iOS/blob/master/RootEncoder/Sources/RootEncoder/library/base/CameraBase.swift#L53

44100 is fixed AudioCodecInitializationFailed.

However, this does not resolve the main freezing issue.

I can provide remote access to my computer via AnyDesk if it would help in diagnosing and resolving the problem. Text me in the telegram @vitkuzmenko

Thank you for the suggestion but I already bought a iPhone 6s for this issue. I will continue with it when I receive the device (According with the web 3-7 days).

Anyway, I need a device with that version soon or later to test this cases

Thank you for the suggestion but I already bought a iPhone 6s for this issue. I will continue with it when I receive the device (According with the web 3-7 days).

Anyway, I need a device with that version soon or later to test this cases

Ok, thank you!

Hello,

I finally have my iPhone 6s but I'm not able to reproduce the freeze in the last version (0.0.7). I have my phone totally static without move.
Can you test it and confirm that the issue is solved?
If not, can you give me a guide to reproduce the error? (tell me if you modified something in the app code or steps to reproduce)
If you use RTMP, the error persist?

About this log:

2024-07-10 17:45:24.352996+0300 app[907:59864] [connection] nw_flow_add_read_request [C2.1 XX.XX.XX.XX:XXX ready channel-flow (satisfied (Path is satisfied), viable, interface: en0, ipv4, dns)] already delivered final read, cannot accept read requests

I can't see that in my xcode console

Hello,

I finally have my iPhone 6s but I'm not able to reproduce the freeze in the last version (0.0.7). I have my phone totally static without move. Can you test it and confirm that the issue is solved? If not, can you give me a guide to reproduce the error? (tell me if you modified something in the app code or steps to reproduce) If you use RTMP, the error persist?

Hello!
Which iOS version on your iPhone 6s?

15.7.1

CameraBase.swift

line 72 set resolution to fhd1920x1080, bitrate: 2048 * 1024

line 168 set .fhd1920x1080

for hd1280x720 similar behavior

For default bitarate 1200 * 1024 with fhd1920x1080 and hd1280x720 works little longer, about 1-2 minutes.

With bitrate 1024 * 1024 for hd1280x720 works perfectly

I was able to reproduce the error (in my case 720p and 3000 * 1024 bitrate). I will try fix it and report back with the result

Hello,

I did a fix to avoid freeze on iPhone 6s.
The problem is that using a high bitrate the socket can't send data fast enough and produce discard frames and bad stream quality. I'm working on it.

Hello,

I did a fix to avoid freeze on iPhone 6s. The problem is that using a high bitrate the socket can't send data fast enough and produce discard frames and bad stream quality. I'm working on it.

Wow! That's great news! I'm eagerly awaiting the release. Thank you for your hard work!

I did the next release with the fix (0.0.8). Currently the stream is not freezed anymore but in somes devices with a high bitrate I already have a problem only with RTSP that produce that the image is like slow (RTMP is working fine).
I'm working to solve it.

I fixed the problem related with RTSP and high bitrate. The problem was related with a method used in packets to manage buffers. I did a new release with all last changed included your changes. You have the changes here:
https://github.com/pedroSG94/RootEncoder-iOS/releases/tag/0.0.9

Closing issue because all errors related with this issue should be fixed.
Open other issue if needed or reopen the issue with more details is the problem persist

Thanks for the fix! I'll test the new release and let you know if anything comes up. Appreciate your help!