Android-ScalableVideoView icon indicating copy to clipboard operation
Android-ScalableVideoView copied to clipboard

[Android] App crash when unmounting video

Open kfiroo opened this issue 7 years ago • 1 comments

Hey, I have route with a react-native-video component, the route is not currently focused, when unmounting the route the app crashes with the following error.

02-13 14:53:42.879  3774  3774 E AndroidRuntime: java.lang.IllegalStateException
02-13 14:53:42.879  3774  3774 E AndroidRuntime: 	at android.media.MediaPlayer.isPlaying(Native Method)
02-13 14:53:42.879  3774  3774 E AndroidRuntime: 	at com.yqritc.scalablevideoview.ScalableVideoView.isPlaying(ScalableVideoView.java:209)
02-13 14:53:42.879  3774  3774 E AndroidRuntime: 	at com.yqritc.scalablevideoview.ScalableVideoView.onDetachedFromWindow(ScalableVideoView.java:84)
02-13 14:53:42.879  3774  3774 E AndroidRuntime: 	at com.brentvatne.react.ReactVideoView.onDetachedFromWindow(ReactVideoView.java:524)
02-13 14:53:42.879  3774  3774 E AndroidRuntime: 	at android.view.View.dispatchDetachedFromWindow(View.java:14555)
02-13 14:53:42.879  3774  3774 E AndroidRuntime: 	at android.view.ViewGroup.removeAllViewsInLayout(ViewGroup.java:4789)
02-13 14:53:42.879  3774  3774 E AndroidRuntime: 	at android.view.ViewGroup.removeAllViews(ViewGroup.java:4735)
02-13 14:53:42.879  3774  3774 E AndroidRuntime: 	at com.facebook.react.views.view.ReactViewManager.removeAllViews(ReactViewManager.java:252)
02-13 14:53:42.879  3774  3774 E AndroidRuntime: 	at com.facebook.react.views.view.ReactViewManager.removeAllViews(ReactViewManager.java:41)
02-13 14:53:42.879  3774  3774 E AndroidRuntime: 	at com.facebook.react.uimanager.NativeViewHierarchyManager.dropView(NativeViewHierarchyManager.java:536)
02-13 14:53:42.879  3774  3774 E AndroidRuntime: 	at com.facebook.react.uimanager.NativeViewHierarchyManager.dropView(NativeViewHierarchyManager.java:533)
02-13 14:53:42.879  3774  3774 E AndroidRuntime: 	at com.facebook.react.uimanager.NativeViewHierarchyManager.dropView(NativeViewHierarchyManager.java:533)
02-13 14:53:42.879  3774  3774 E AndroidRuntime: 	at com.facebook.react.uimanager.NativeViewHierarchyManager$1.onAnimationEnd(NativeViewHierarchyManager.java:420)
02-13 14:53:42.879  3774  3774 E AndroidRuntime: 	at com.facebook.react.uimanager.layoutanimation.LayoutAnimationController$1.onAnimationEnd(LayoutAnimationController.java:131)
02-13 14:53:42.879  3774  3774 E AndroidRuntime: 	at android.view.animation.Animation$3.run(Animation.java:376)
02-13 14:53:42.879  3774  3774 E AndroidRuntime: 	at android.os.Handler.handleCallback(Handler.java:739)
02-13 14:53:42.879  3774  3774 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:95)
02-13 14:53:42.879  3774  3774 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:148)
02-13 14:53:42.879  3774  3774 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:5417)
02-13 14:53:42.879  3774  3774 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
02-13 14:53:42.879  3774  3774 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
02-13 14:53:42.879  3774  3774 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

From what I could find in the docs:

IllegalStateException if the internal player engine has not been initialized or has been released.

My Video component is in a background route (i.e. there is a route on top of it) so maybe the video gets release when not visible and that causes the isPlaying to throw?

Thanks!

kfiroo avatar Feb 13 '17 13:02 kfiroo

@kfiroo Thanks for posting this! I was getting the same issue.

Looks like the specific issue has been fixed in ScalableVideoView thanks to this Pull Request: https://github.com/yqritc/Android-ScalableVideoView/pull/12 .

On the React-Native-Video side, we need to use the latest version of ScalableVideoView (1.0.4), and make sure the release() method has been called correctly in ReactVideoView.java.

I just opened a PR for that here: https://github.com/react-native-community/react-native-video/pull/533

dojiboy9 avatar Mar 15 '17 19:03 dojiboy9