Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a crash issue on Android "Fatal Exception: java.lang.IllegalStateException" #353

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

thanakij
Copy link

Hi,

Our team have experience a crash issue reported by Crashlytics saying "Fatal Exception. This YouTubePlayer has been released (YouTubePlayerController.java:315)"

We are using latest commit #1c2d9dc (at the time of writing) for our package.json.

I have tried to strengthen the code with the "try ... catch" block and
would like to submit a pull request for review.

Thanks!

…Exception. This YouTubePlayer has been released (YouTubePlayerController.java:315)'
…Can not perform this action after onSaveInstanceState (YouTubeView.java:50)'
@chrismpalmer
Copy link

chrismpalmer commented Jan 30, 2019

Did this work for you? I was reviewing your code. I was heading down the same lines. Just wondering if it's working? @thanakij

@thanakij
Copy link
Author

Did this work for you? I was reviewing your code. I was heading down the same lines. Just wondering if it's working? @thanakij

There are no Crashlytics report of the same errors so far.

However, I have found one new issue, "No view found for id 0x36e7 (unknown) for fragment VideoFragment{664a5dc #0 id=0x36e7}. (OS: FragmentManager.java:1004)".

This StackOverflow discussion reveals that it may relate to my changes. The error is likely from fragmentManager.beginTransaction().add(getId(), mVideoFragment) and for some reason such view cannot be found.

@DanielLuu
Copy link

@thanakij does your fix prevent the new issue?

@thanakij
Copy link
Author

thanakij commented Mar 21, 2019

No, like discussed earlier, the fix incurs new issue. I believe this is because the real root cause is not resolved yet. Eventually, we simply get a different error message when crashing (but it is sure less often). Let's look at #336. It also tried to tackle the same original issue.

@thanakij
Copy link
Author

thanakij commented Jun 6, 2019

For anybody who visits this, I have decided to drop this react-native-youtube dependency from my project as this lib is pretty much dead and unmaintained.

Next, I have replaced it with WebView for now.

<WebView
    style={{ flex: 1, height: VIDEO_HEIGHT }}
    javaScriptEnabled={true}
    source={{ uri: uri }}
/>

It works well so far. In addition, you may have to use react-native-android-fullscreen-webview-video to enable "fullscreen" mode for Android.

@davidohayon669
Copy link
Owner

@thanakij maybe your issue has something to do with #357? Please offer a conclusive PR so I can understand the issue and we can fix this

@thanakij
Copy link
Author

@davidohayon669 #357 is also using commitAllowingStateLoss(), but like what I experienced with my own pull request, it probably would result in another issue, "No view found".

For commit(), if there is a state error, it will throw an exception. However, by using commitAllowingStateLoss(), if there is a state error, the error is still there but Android will not throw an exception and we wouldn't know.

In short, it was meant for a quick fix and many suggested to use this method only for a last resort.

I don't know what is the real root cause for this IllegalStateException but something like #336 looks interesting to me because it added mPlayerAvailable for safety..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants