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

solve the memory leak on Android and avoid the crash on kitkat #1328

Merged
merged 3 commits into from
Dec 13, 2018

Conversation

linguokun1
Copy link
Contributor

@linguokun1 linguokun1 commented Nov 15, 2018

Solve the memory leak on Android and avoid the crash on Xiaomi Phone M4's kitkat rom when call mp.selectTrack(0);

@@ -565,7 +572,10 @@ public void run() {
}

// Select track (so we can use it to listen to timed meta data updates)
mp.selectTrack(0);
try{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you should add a comment why this try catch is there for future contributors

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for avoiding crash when drag the video progress on some old android phone. It will throw error code -1010, this error code was define in MediaPlayer class as below:
/** Bitstream is conforming to the related coding standard or file spec, but
* the media framework does not support the feature. */
public static final int MEDIA_ERROR_UNSUPPORTED = -1010;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cobarx What do you think? IMHO this should be added as a code comment to not confuse contributors in the future!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@n1ru4l Absolutely, any special conditions like this should always be commented. Otherwise, it's impossible to refactor them later since you can't know if they're still relevant.

I will get this tested and merged tomorrow. Sorry about the delay, I've had very little time to work on the project lately.

@evanjmg
Copy link

evanjmg commented Dec 11, 2018

Please test, review, and merge. I'm getting this as well - 10% of my users are getting this crash

@n1ru4l
Copy link
Contributor

n1ru4l commented Dec 11, 2018

@evanjmg Sorry to hear about your issues!

In such an urgent case you still have to option to either use https://www.npmjs.com/package/patch-package or fork!

@evanjmg
Copy link

evanjmg commented Dec 11, 2018

already forked

@cobarx
Copy link
Contributor

cobarx commented Dec 13, 2018

Ok, I looked through this code and it seems like blindly selecting track 0 isn't useful unless track 0 happens to contain timed metadata. So I've made it look to see if there is even any timed metadata and only select those tracks. I can't find a sample stream to test this, so I'm just going to cross my fingers and hope this works properly. @RWOverdijk any chance you can test the updated code?

I'm going ahead and merging this. @evanjmg and @linguokun1 would you mind testing the updated code to make sure it fixes the issue for you?

@cobarx cobarx merged commit 52334f0 into TheWidlarzGroup:master Dec 13, 2018
@evanjmg
Copy link

evanjmg commented Dec 16, 2018

Nice refactor. So far so good; it’s an improvement for me. I’ll let you know if I have any more issues.

@linguokun1
Copy link
Contributor Author

@cobarx I have used the code I modifing in my project, It's ok and no problem till now.

beauner69 pushed a commit to beauner69/react-native-video that referenced this pull request Oct 10, 2019
solve the memory leak on Android and avoid the crash on kitkat

(rebased from commit 52334f0)
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