apivideo / api.video-reactnative-live-stream

React Native RTMP live stream client. Made with ♥ by api.video
https://api.video
MIT License
172 stars 33 forks source link

[Bug]: Crash on android, Error while updating property 'video' #84

Open talhatsk opened 1 month ago

talhatsk commented 1 month ago

Version

v2.0.0

Which operating systems have you used?

Environment that reproduces the issue

Tested on Xiaomi Redmi Note 11S android 13

Is it reproducible in the example application?

Not tested

RTMP Server

*

Reproduction steps

I have a component where <ApiVideoLiveStreamView.../> is placed. Upon mounting and unmounting the component for few time ( more than 3 times) without even connecting to the server, the app gets crashed.

Expected result

the app should not crash

Actual result

the app is crashing on mounting/unmounting the component containing <ApiVideoLiveStreamView.../>.

Additional context

react native: 0.71.13

Relevant logs output

FATAL EXCEPTION: main
com.facebook.react.bridge.JSApplicationIllegalArgumentException: Error while updating property 'video' of a view managed by: ApiVideoLiveStreamView
    at com.facebook.react.uimanager.ViewManagersPropertyCache$PropSetter.updateViewProp(ViewManagersPropertyCache.java:101)
    at com.facebook.react.uimanager.ViewManagerPropertyUpdater$FallbackViewManagerSetter.setProperty(ViewManagerPropertyUpdater.java:136)
    at com.facebook.react.uimanager.ViewManagerPropertyUpdater.updateProps(ViewManagerPropertyUpdater.java:56)
    at com.facebook.react.uimanager.ViewManager.updateProperties(ViewManager.java:86)
    at com.facebook.react.uimanager.ViewManager.createViewInstance(ViewManager.java:188)
    at com.facebook.react.uimanager.ViewManager.createView(ViewManager.java:115)
    at com.facebook.react.uimanager.NativeViewHierarchyManager.createView(NativeViewHierarchyManager.java:281)
    at com.facebook.react.uimanager.UIViewOperationQueue$CreateViewOperation.execute(UIViewOperationQueue.java:194)
    at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.dispatchPendingNonBatchedOperations(UIViewOperationQueue.java:1110)
    at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:1081)
    at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java:29)
    at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:175)
    at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame(ChoreographerCompat.java:85)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1503)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1513)
    at android.view.Choreographer.doCallbacks(Choreographer.java:1128)
    at android.view.Choreographer.doFrame(Choreographer.java:1037)
    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1481)
    at android.os.Handler.handleCallback(Handler.java:942)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:211)
    at android.os.Looper.loop(Looper.java:300)
    at android.app.ActivityThread.main(ActivityThread.java:8503)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:561)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:954)
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at com.facebook.react.uimanager.ViewManagersPropertyCache$PropSetter.updateViewProp(ViewManagersPropertyCache.java:93)
    at com.facebook.react.uimanager.ViewManagerPropertyUpdater$FallbackViewManagerSetter.setProperty(ViewManagerPropertyUpdater.java:136)
    at com.facebook.react.uimanager.ViewManagerPropertyUpdater.updateProps(ViewManagerPropertyUpdater.java:56)
    at com.facebook.react.uimanager.ViewManager.updateProperties(ViewManager.java:86)
    at com.facebook.react.uimanager.ViewManager.createViewInstance(ViewManager.java:188)
    at com.facebook.react.uimanager.ViewManager.createView(ViewManager.java:115)
    at com.facebook.react.uimanager.NativeViewHierarchyManager.createView(NativeViewHierarchyManager.java:281)
    at com.facebook.react.uimanager.UIViewOperationQueue$CreateViewOperation.execute(UIViewOperationQueue.java:194)
    at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.dispatchPendingNonBatchedOperations(UIViewOperationQueue.java:1110)
    at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:1081)
    at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java:29)
    at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:175)
    at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame(ChoreographerCompat.java:85)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1503)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1513)
    at android.view.Choreographer.doCallbacks(Choreographer.java:1128)
    at android.view.Choreographer.doFrame(Choreographer.java:1037)
    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1481)
    at android.os.Handler.handleCallback(Handler.java:942)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:211)
    at android.os.Looper.loop(Looper.java:300)
    at android.app.ActivityThread.main(ActivityThread.java:8503)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:561)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:954)
Caused by: android.media.MediaCodec$CodecException: Error 0xfffffff4
    at android.media.MediaCodec.native_configure(Native Method)
    at android.media.MediaCodec.configure(MediaCodec.java:2214)
    at android.media.MediaCodec.configure(MediaCodec.java:2130)
    at io.github.thibaultbee.streampack.internal.encoders.MediaCodecEncoder.createCodec(MediaCodecEncoder.kt:184)
    at io.github.thibaultbee.streampack.internal.encoders.MediaCodecEncoder.configure(MediaCodecEncoder.kt:200)
    at io.github.thibaultbee.streampack.streamers.bases.BaseStreamer.resetVideo(BaseStreamer.kt:365)
    at io.github.thibaultbee.streampack.streamers.bases.BaseStreamer.stopStream$suspendImpl(BaseStreamer.kt:322)
    at io.github.thibaultbee.streampack.streamers.bases.BaseStreamer$stopStream$1.invokeSuspend(Unknown Source:11)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
    at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:280)
    at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:85)
    at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)
    at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source:1)
    at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38)
    at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source:1)
    at io.github.thibaultbee.streampack.streamers.bases.BaseCameraStreamer.stopPreview(BaseCameraStreamer.kt:120)
    at io.github.thibaultbee.streampack.streamers.bases.BaseCameraStreamer.release(BaseCameraStreamer.kt:130)
    at io.github.thibaultbee.streampack.streamers.bases.BaseStreamer.configure(BaseStreamer.kt:244)
    at video.api.livestream.ApiVideoLiveStream.setVideoConfig(ApiVideoLiveStream.kt:127)
    at video.api.reactnative.livestream.LiveStreamView.setVideoConfig(LiveStreamView.kt:134)
    at video.api.reactnative.livestream.LiveStreamViewManager.setVideo(LiveStreamViewManager.kt:67)
ThibaultBee commented 1 month ago

android.media.MediaCodec$CodecException: Error 0xfffffff4 is not really explicit. As a short term solution, I will mitigate this issue by not calling Codec configure when stopStream is call and it is not streaming.

In the current implementation, the codec (Android API called MediaCodec) is released and reopen when calling stopStream so it is quickly ready for a new shot. Currently, I am reworking the native Android component. I already changed that behavior so that the MediaCodec won't be open/close anymore when calling stopStreaming.

talhatsk commented 1 month ago

android.media.MediaCodec$CodecException: Error 0xfffffff4 is not really explicit. As a short term solution, I will mitigate this issue by not calling Codec configure when stopStream is call and it is not streaming.

In the current implementation, the codec (Android API called MediaCodec) is released and reopen when calling stopStream so it is quickly ready for a new shot. Currently, I am reworking the native Android component. I already changed that behavior so that the MediaCodec won't be open/close anymore when calling stopStreaming.

How can i fix this crash right now? FYI i'm not calling stopStreaming while mounting or unmounting the component, it is only called when the stream is connected to RTMP server.

ThibaultBee commented 1 month ago

Wait for a new release. stopStreaming is used internally when the application is unmounting.

talhatsk commented 1 month ago

Wait for a new release. stopStreaming is used internally when the application is unmounting.

okay, thanks

MAzeem6778 commented 1 month ago

Hi @ThibaultBee,

I'm experiencing the same issue. As you mentioned, it will be fixed in the upcoming version. Could you please let me know when we can expect the new version to be released?

xoraingroup commented 1 month ago

We don't have source code to get you a PR and its affecting our tests alot making android more or less unreliable. Any rough eta on this?

ThibaultBee commented 1 month ago

Fixes in https://github.com/apivideo/api.video-android-live-stream/commit/276020aa96d113593be7280be5a9c228c25d1ef6

talhatsk commented 1 month ago

Fixes in apivideo/api.video-android-live-stream@276020a

Great, have you released it, how soon can we test it?

talhatsk commented 3 weeks ago

Fixes in apivideo/api.video-android-live-stream@276020a

when are you planning to release it ? @ThibaultBee

ThibaultBee commented 1 week ago

Hi, I have made the fixes in the main branch. Could you test on the main branch?

talhatsk commented 1 week ago

Hi, I have made the fixes in the main branch. Could you test on the main branch?

its fixed step tried:

  1. open application
  2. went into background application didn’t crash
talhatsk commented 21 hours ago

@ThibaultBee when do you plan to release it?.