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

Feature/Android: fallback option for player reparenting #497

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

kot331107
Copy link
Contributor

@kot331107 kot331107 commented Feb 14, 2025

Description

  1. Adds a fallback option on reparent to search for ReactRootView downward from the top of the view tree if there's no ReactRootView instance found among the direct parents of the player.
  2. Reparents on PiP events too (disabled by default as experimental)
  3. New build flag to turn off new PiP reparenting behavior

Test-plan

  1. Run a test app
  2. Watch inline player
  3. Turn on fullscreen.
  4. Expected: it should reparent, no black screen, no crashes, playback works and controls layer should work too
  5. Repeat the same in steps 1-2 and then move the app to PiP.
  6. Expected 2: it should show only the video content in PiP, no nav bars, nothing else besides the video.

@kot331107
Copy link
Contributor Author

@tvanlaerhoven please put this PR on hold for a while until our QA folks test these changes over our apps. Thank you.

var parent: ViewParent? = view?.parent
while (parent != null && parent !is T) {
parent = parent.parent
inline fun <reified T : View> ViewGroup.getClosestParentOfType(upward: Boolean = true): T? {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tvanlaerhoven I could move this to some util file, any thoughts? or better keep it here?

Copy link
Member

Choose a reason for hiding this comment

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

@kot331107 You can move it if you like. It could be useful somewhere else as well indeed.

Comment on lines +249 to +250
?: (activity.window.decorView.rootView as? ViewGroup)
?.getClosestParentOfType(false)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

would work as a fallback option, so should be safe to merge for current clients I guess. The part to test is PiP reparenting but we set the build flag to false by default as it is experimental

Copy link
Member

Choose a reason for hiding this comment

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

Just for my understanding: in which case did the upwards search for a suitable root fail?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in our apps it happens when we switch on the fullscreen mode from inline player. For some reason the React Root view doesn't exist in the direct player's parents in this particular scenario. Also it happens only on the second and any subsequent times. The first attempt it just works fine with the upward search.

@kot331107 kot331107 changed the title Feature/Fallback for reparenting Feature/Android: fallback option for player reparenting Feb 14, 2025
@kot331107 kot331107 marked this pull request as draft February 18, 2025 20:25
@kot331107
Copy link
Contributor Author

converting to draft for now as we see some side effects in our apps we'd like to manage

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.

2 participants