-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Crash when tapping the search widget while in PIP #24040
Comments
@Mugurell , can I explore this issue? |
Would be great to but the issue here might be more complex. |
@Mugurell , Thank You !! I'll be sure to delve deep into the given context. |
@Mugurell , it's interesting and I'm getting to know more about the main core of the app. Code snippet from BaseBrowserFragment
The following are the two scenarios I tried. We come to the browser((BrowserFragment) either from the search widget or from the launcher
We are still in BrowserFragment when we reach 3. The flow and the method pipModeChanged() has the BrowserFragement context But in the following scenario
We are in the HomeFragment when we search from the search widget. Meanwhile if the flow and the method pipModeChanged() has access to the BrowserFragment context before its stopped and destroyed, the code will run fine. Otherwise we will get the "java.lang.IllegalStateException: Fragment BrowserFragment{15d201b} (8cc9275a-45e9-4fbe-9a4f-9947a4e10347) not attached to a context." Need to explore more... |
Maybe we could just add a check for if the BrowserFragment But ideally we should try avoiding the race between these two fragments (actually between |
Thank You @Mugurell , I've already tried with isAdded and the exception is not thrown. If we catch the exception pipModeChanged() might not be executed when onPictureInPictureModeChanged(false) is invoked. When the search is from search widget, I'm not sure whether we need to execute pipModeChanged() when onPictureInPictureModeChanged(false) is invoked |
@Mugurell , I'm not sure whether the pipModeChanged() method might be useful in the following scenario
As you mentioned if the race between StartSearchIntentProcessor#process and BaseBrowserFragment#pipModeChanged is avoided we can prevent the issue from happening. For now I'm modifying pipModeChanged method as
The issue is gone but the screen is locked to landscape orientation. There are few issues in orientation #22471 (comment) I'm interested to work on this orientation issue as well. Will debug and explore |
@Mugurell , I think the purpose of MediaSessionFullscreenFeature is to enable/disable full screen mode when a full screen event is dispatched from Gecko engine. This feature is used only when a video is played in the browser. https://github.com/mozilla-mobile/android-components/blob/01012c16f9e3aab667aaa1ad9065d87bf1bad9ce/components/feature/media/src/main/java/mozilla/components/feature/media/fullscreen/MediaSessionFullscreenFeature.kt#L42 is called more than once even after the screen is set to full screen mode. Probably the flow is emitting any browser state updates after the fullscreen mode is set. I also noted that couple of times the video is played in portrait mode. Another possible issue that I noticed.. |
When the search event is from the search widget, the search fragment opens after the screen is unlocked. This avoids the issue of the search page opening in landscape mode
@Mugurell , to avoid the crash when the search widget is tapped and to open the search page in portrait mode, I've modified the StartSearchIntentProcessor and added a method in BrowserStore. Just wanted to make sure I'm going in the right direction. Suggestions would be helpful. I've created a draft PR #24951. Still few modifications need to be done.. for instance onBackPressed() is called more than once.. |
…t is clicked while PIP mode is active Unlocks the screen orientation in StartSearchIntentProcessor and navigates to the HomeFragment. The onStop() method in BaseBrowserFragment handles the fullscreen exit functionality. Co-Authored-By: Mugurell <[email protected]>
… is clicked while PIP mode is active Reversed the previous changes. To fix the crash, verified whether the fragment is added to the activity in pipModeChanged function. Fullscreen media clean up is done in onstop() method of BaseBrowserFragment Co-Authored-By: Mugurell <[email protected]>
…t is clicked while PIP mode is active
…t is clicked while PIP mode is active
…t is clicked while PIP mode is active Exiting full screen mode is handled in pipModeChanged function only if the BrowserFragment is attached to the activity. This avoids the crash. HomeActivity checks for any active media tab when a new intent arrives and executes the full screen exit logic
… is clicked while PIP mode is active When the search event is from the search widget while PIP is active, the search fragment opens after the screen is unlocked. This avoids the issue of the search page opening in landscape mode and also the app doesn't crash. Co-Authored-By: Mugurell <[email protected]>
…ile PIP mode is active (#25410) When the search event is from the search widget while PIP is active, the search fragment opens after the screen is unlocked. This avoids the issue of the search page opening in landscape mode and also the app doesn't crash. Co-Authored-By: Mugurell <[email protected]> Co-authored-by: indu <[email protected]>
Verified as fixed in the latest Nightly from 05/30 with Google Pixel 6 (Android 12). The app no longer crashes after tapping the search widget while in Pip mode. |
Prerequisites:
Have the search widget added to homescreen
STRs:
Expected result:
Actual result:
PipToSearchCrash.mp4
┆Issue is synchronized with this Jira Task
The text was updated successfully, but these errors were encountered: