DescriptionMac: Fix black flashing during tab switch
This was not a new bug, but rather a worse manifestation of an existing
bug.
The existing bug occurred when a ui::Compositor was recycled. That is,
when the compositor was detached from one NSView and then attached to a
different NSView.
The desired behavior is that, at the instant that the ui::Compositor is
detached (in particular, ImageTransportFactory::
SetCompositorSuspendedForRecycle, called OnCompositorRecycled before
this patch) is called, no more frames should be drawn into the
compositor's output surface.
This was previously accomplished by doing two things
1. Locking the ui::Compositor until the new NSView has a frame for it.
2. Making GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped
not draw any frames that come in from the GPU process until after a
call to GpuBrowserCompositorOutputSurface::SwapBuffers has occurred.
This is to prevent swaps that were issued by the browser prior to
the ui::Compositor being recycled from being shown.
The assumption here was that the call to
GpuBrowserCompositorOutputSurface::SwapBuffers would only be in
response to new frame belonging to the new NSView. This is not a valid
assumption now that the ui::Compositor uses a cc::Scheduler. In
particular, the ui::Compositor may draw frames that have already been
committed, even while it is locked. These previously-committed frames
will call SwapBuffers when they are being drawn (which the logic will
erroneously assume means that a frame from the new NSView is ready).
To fix this, change this logic to make the output surface not draw any
frames until the ui::Compositor commits a new frame and
GpuBrowserCompositorOutputSurface::SwapBuffers is called.
Also, the DiscardBackbuffer which is done to ensure that the same
CALayer is not sent to two different tabs is now done immediately
after the ui::Compositor does its commit for the new NSView (but
before it does a draw) instead of being done immediately when the
old NSView is removed.
The old location was incorrect -- if there was a draw in flight, it would
cause the backbuffer to be reallocated, and then the same CALayer
would be used for the two tabs. Also, if the draw was a partial swap,
then that frame would have black in the areas that were not drawn by
the partial swap -- then, because the same CALayer was being used
for the two tabs, we would get a flash of the semi-black frame in the
new tab.
BUG=477413
Committed: https://crrev.com/8d5d7278d7e06214bb87f170cda5c9ce9cf0c325
Cr-Commit-Position: refs/heads/master@{#326181}
Patch Set 1 #Patch Set 2 : Wait for swap to draw frames #Messages
Total messages: 10 (2 generated)
|