api.video-reactnative-live-stream icon indicating copy to clipboard operation
api.video-reactnative-live-stream copied to clipboard

[Bug]: App interrupts streaming and freezes when trying to stop stream

Open Pitros opened this issue 2 years ago • 8 comments

Version

v1.2.3

Which operating systems have you used?

  • [X] Android
  • [ ] iOS

Environment that reproduces the issue

Samsung Galaxy S9 - Android 10

Is it reproducible in the example application?

Yes

RTMP Server

rtmp://***.in.streamster.io/in (key: ***)

Reproduction steps

  1. Start streaming with any parameters
  2. After some time (usually around 10-15 seconds) streaming will stop - server will not receive data
  3. Preview will still work fine
  4. Try to stop streaming, app will freeze but preview will be visible

Expected result

App does not freeze

Actual result

App freezes, no logs on react-native side, no errors in logcat, only anr crash report is saved

https://gist.github.com/Pitros/e3d1239dd1875538d57d3b7725bbf281

Additional context

Streaming is also stuttering on this device, other phone (Galaxy S20) does not stutter and does not have this freeze issue.

Relevant logs output

No response

Pitros avatar Feb 13 '23 16:02 Pitros

Hi,

There seems to have a lot a lock thread in the ANR. It is hard to see what is wrong as there is a mix with your application threads. Could you try to reproduce directly with our internal Android library: https://github.com/ThibaultBee/StreamPack/suites/10371571998/artifacts/511567553?


About the stuttering, could you test locally with ffmpeg:

ffplay -listen 1 -i rtmp://0.0.0.0:1935/s/streamKey

And on your phone, set the RTMP url to your computer IP.

ThibaultBee avatar Feb 14 '23 09:02 ThibaultBee

@ThibaultBee so i checked stuttering locally and it works fine, totally smooth, but still with rmtp server from restream.io it's having difficulties. Every few seconds there's pause for second or multiple seconds. Also there's warning:

Check your encoder settings
Keyframe interval: 0.589
Recommended: 2

Tried to reproduce those stutterings on emulator, seems like Pixel 5 API 30 has some issues, not sure if that will apply to you as well.

Here's crash log from your app related to app not responding: https://gist.github.com/Pitros/48a0a8bc4a1575509c5e59dddb69084c

Pitros avatar Feb 17 '23 11:02 Pitros

Not sure it is going to fix your issue, but to respect the key frame interval required, you can set:

video.gopDuration = 2

See README.md:

video: {
    ...
    // duration between 2 key frames in seconds
    gopDuration: number;
  };

ThibaultBee avatar Feb 17 '23 14:02 ThibaultBee

I am also seeing a similar issue with the app and using the RTMP server from https://github.com/gwuhaolin/livego.

The server throws an error while using the library

WARN[2023-02-23T11:11:42+05:30] rtmp.go:419 github.com/gwuhaolin/livego/protocol/rtmp.(*VirReader).Read.func1() rtmp read packet panic: runtime error: slice bounds out of range [:12910591] with capacity 512000

but other libraries like https://github.com/NodeMedia/react-native-nodemediaclient working fine with the server.

Update: my Settings were:

                camera="back"
                video={{
                    fps: 30,
                    resolution: '480p',
                    bitrate: 500000,
                    gopDuration: 1,
                }}
                audio={{
                    bitrate: 128000,
                    sampleRate: 44100,
                    isStereo: true,
                }}

tinkalgogoi avatar Feb 23 '23 06:02 tinkalgogoi

Any update ? Having the same issue with a Samsung Galaxy S9 on Android 10 too

gokugen avatar Feb 27 '23 09:02 gokugen

I saw that it depends on whether we use the front or back camera too.

When i use the phone's back camera with a bitrate of 2000000 and a gopDuration equal to 1 I can normaly stream but if I try with the front camera I can't view my stream on my NodeMediaServer.

gokugen avatar Feb 28 '23 06:02 gokugen

Ok, I have the feeling there are several issues described here. Let's focus on the freeze on stopStream. Please open other issues for any other odd behavior.

Is the freeze on stopStream random? Does it only appear on your S9/Android 10? As this library depends on another live streaming library, could you test to reproduce directly on it? https://github.com/ThibaultBee/StreamPack You can download it here: https://github.com/ThibaultBee/StreamPack/suites/10371571998/artifacts/511567553

ThibaultBee avatar Mar 02 '23 14:03 ThibaultBee

Could you test the original issue with 2.0.0?

ThibaultBee avatar May 03 '24 09:05 ThibaultBee

@ThibaultBee thanks for keeping the lib updated!

It seems like it's stable now, tried all sort of actions with updated lib and didn't crash. Also now bitrate can be changed dynamically.

Pitros avatar May 07 '24 16:05 Pitros

Ok. Thanks. I am closing this.

ThibaultBee avatar May 13 '24 07:05 ThibaultBee