weblayer: ensures WebContents doesn't hide during rotation
During a rotation, when BrowserFragment is retained and the containing activity is recreated, the following sequence of events happens: 1. destroyAttachmentState 2. createAttachmentState 3. onFragmentStart <- when this is called isAttachedToWindow() is false 4. onFragmentResume <- when this is called isAttachedToWindow() is false BrowserImpl maintained some state to avoid doing certain things during a configuration change, but that state was reset in onFragmentStart(). The problem is onFragmentStart() triggers updating the visibility of the WebContents, and at the time onFragmentStart() is called isAttachedToWindow() returns false, meaning the WebContents was hidden. Hiding the WebContents is bad for sites like youtube which stop playing video. Then fix is to delay resetting state until onViewAttachedToWindow(). There is one other subtle change to TabImpl. Specifically getViewController() is changed to return null if the BrowserViewController hasn't been updated yet. This is necessary because the code updates the active state of the tabs *and* then the BrowserViewController. This means if when updating the active state of a Tab the Tab calls back to BrowserViewController the state isn't right, and may cause NPEs. BUG=1075744 TEST=TabTest.testRotationDoesntChangeVisibility Change-Id: I14e68251541f4387338e5548d4d78daac7419935 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2439556Reviewed-by:Bo <boliu@chromium.org> Reviewed-by:
Evan Stade <estade@chromium.org> Commit-Queue: Scott Violet <sky@chromium.org> Cr-Commit-Position: refs/heads/master@{#813197}
Showing
Please register or sign in to comment