Skip to content

fix(android): fix bugs related Android PIP listeners #4441

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

Merged

Conversation

YangJonghun
Copy link
Contributor

@YangJonghun YangJonghun commented Mar 1, 2025

Summary

fix(android): fix bugs related Android PIP listeners

Motivation

  • Fixes bug that entire app enters PIP without player on Android 13+

  • fix [BUG]: PictureInPictureUtil.calcPictureInPictureAspectRatio #4434

    • This bug occurs on Android 7 through Android 12 that use OnUserLeaveHint to enable PIP.
    • Fatal Exception: java.lang.NullPointerException : Parameter specified as non-null is null: method com.brentvatne.exoplayer.PictureInPictureUtil.calcPictureInPictureAspectRatio, parameter player

Changes

  • When using onUserLeaveHint, removeOnUserLeaveHintListener was not properly removing a previously registered callback that referenced another Runnable. Fix to explicitly declare that onUserLeaveHintCallback is a Runnable so that the reference is guaranteed to be the same.
  • Because all PIP listeners registered in constructor, and callback can be called before player is created, which is registered asynchronously. Modify lifecycle to match cycle in which players are created and deleted.

Test plan

Modify code like below within ReactExoplayerView

- mainHandler.postDelayed(mainRunnable, 1);
+ mainHandler.postDelayed(mainRunnable, 5000);
  1. prepare the general screen, player screen, and enter the screen with the player (proceed with listener registration).
  2. Enter the previous screen and delete the listener.
  3. Enter the player screen again.

Verify that the PIP does not work when there is no player in steps 1 and 3, and that the PIP works correctly when there is a player.

@KrzysztofMoch KrzysztofMoch requested a review from freeboub March 4, 2025 14:10
@freeboub
Copy link
Collaborator

freeboub commented Mar 5, 2025

Looks good to me! @MdAbubakar by curiosity, did you test this PR ?
Edit: I sa yo already tested it, so OK for me !

@MdAbubakar
Copy link

Looks good to me! @MdAbubakar by curiosity, did you test this PR ? Edit: I sa yo already tested it, so OK for me !

@freeboub yes sir I have checked this PR and major issues are fixed but there are some other device specific and android version specific issues those are related to all these issues I think so will see afterwards if I got crashes.

@freeboub and @YangJonghun Thank you for your response.

@KrzysztofMoch KrzysztofMoch merged commit 82f5f3d into TheWidlarzGroup:master Mar 6, 2025
3 checks passed
@YangJonghun YangJonghun deleted the fix/fix-pip-listener branch March 6, 2025 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

[BUG]: PictureInPictureUtil.calcPictureInPictureAspectRatio
4 participants