Open Bug 1494522 Opened 6 years ago Updated 20 days ago

Scrollbar and close button flicker and wobble when window horizontally resizes with WebRender enabled

Categories

(Core :: Graphics: WebRender, defect, P2)

x86_64
Windows 10
defect

Tracking

()

People

(Reporter: cpearce, Unassigned)

References

(Blocks 2 open bugs)

Details

Attachments

(6 files, 1 obsolete file)

With WebRender enabled, if I resize the Firefox window horizontally on its left hand side, I see the Firefox window's right hand side flicker and wobble.

You need to resize pretty quickly.

Win10 x64, Nightly 2018-09-26, NVIDIA GTX1060 driver 24.21.14.1163.

(See also 1486958 for similar bug.)
See Also: → 1486958
Component: Graphics → Graphics: WebRender
bug 1486958 made flush rendering to sync. But it did not address the STR.

bug 1486958 addressed the problem of horizontally on its right hand side.
Hey Chris -- Would you be comfortable taking this as your next bug?
Flags: needinfo?(cpearce)
(In reply to Maire Reavy [:mreavy] Plz needinfo from comment #2)
> Hey Chris -- Would you be comfortable taking this as your next bug?

Can have a go. Will assign myself when I'm ready to start, in case someone else can get to it first...
Here's a screencast of me taking a profile, the profile is https://perfht.ml/2ASWxwV
(In reply to Chris Pearce (:cpearce) from comment #4)
> Created attachment 9023491 [details]
> bug1494522.mp4; https://perfht.ml/2ASWxwV
> 
> Here's a screencast of me taking a profile, the profile is
> https://perfht.ml/2ASWxwV

Markus, can you make any sense of the profile https://perfht.ml/2ASWxwV and the screencast of capturing the profile in attachment 9023491 [details]?
Flags: needinfo?(cpearce) → needinfo?(mstange)
I know you're taking this one, Chris -- so I'm just assigning to make that clear.
Assignee: nobody → cpearce
So there are at least two problems here.

1. We're not calling WebRenderLayerManager::FlushRendering() when we resize the LHS of the window rightwards. This means we don't force the chrome/content to repaint, which results in the glitches in chrome on the top-RHS. (We do call WebRenderLayerManager::FlushRendering() when we resize the RHS rightwards, but not leftwards).
2. When we resize the LHS leftwards, we appear to paint the window wider than it should be; so we end up rendering some of the window to the right of the RHS, even though we're making the window wider on the LHS and the RHS shouldn't be moving right. It's almost as if we're rendering he window for one frame at its post-resize width at the pre-resize screen position.
Flags: needinfo?(mstange)
I note that the chrome doesn't flicker or appear to draw outside of the bounds of the window upon resize if I disable DirectComposition via gfx.webrender.dcomp-win.enabled=false.
Temporal patch to wait for all GPU tasks during resizing window. It seems to address the flicker for me. But sometimes resizing window was very slow.
Comment on attachment 9032077 [details] [diff] [review]
temporal patch - Wait for all GPU tasks during resizing window

Review of attachment 9032077 [details] [diff] [review]:
-----------------------------------------------------------------

Unfortunately, this didn't solve the glitches for me.

::: gfx/webrender_bindings/RenderCompositorANGLE.cpp
@@ +362,5 @@
>  
> +void
> +RenderCompositorANGLE::WaitForAllGPUTasks()
> +{
> +  while (mWaitForPresentQueries.size() >= 0) {

while (mWaitForPresentQueries.size() > 0)

That is, greater than, not greater than or equal to, otherwise we'll call front() on an empty queue, and get undefined behaviour.

I think my theory previously reported in the standup about the dcomp double or triple buffer containing the frame at the old dimensions is incorrect; when we present in dcomp with a sync interval of 0, we overwrite everything in dcomp's queue and the overwriting frame should be rendered at the next vsync. So when we receive a display list for the new window size, since we only present with a sync interval of 0, the display list for the new window size should render at the next vsync.

The basic compositor can handle resizing without glitching, even in a debug build.

There's lots of good info here about Windows and resize glitches:
https://stackoverflow.com/questions/53000291/how-to-smooth-ugly-jitter-flicker-jumping-when-resizing-windows-especially-drag/53000292#53000292

The basic premise there is that if you don't paint your window within some time limit after receiving a WM_NCCALCSIZE, Windows tries to help by blitting whatever was in the client area before resize to where it thinks it should be in the client area after resize, adding padding to fill the extra space created when enlarging (filled with a background color), or clipping off some of the window when shrinking. It's this interpolated frame rendered with padding/clipping that causes glitches.

Ultimately I think the problem is that when the parent window resizes, if we don't manage to update the compositor's child window in the GPU process before the time limit, Windows will will try to blit the window old contents to the window's new location/size and stuff things up.

I think this is exacerbated by the fact that our child window is in a separate GPU process.

I've patched RenderCompositorANGLE to log the number of vsyncs reported by the dcomp's swap chain stats, and that shows there are multiple vsyncs occurring during the resize in which we don't have a display list for the new window size.

I've tried various things suggested in that stackoverflow post to suppress Windows blitting the window's client area, but not had any success.

I note that Chrome has this bug too.

Attachment #9032077 - Attachment is obsolete: true
Assignee: cpearce → sotaro.ikeda.g
Assignee: sotaro.ikeda.g → nobody
No longer blocks: stage-wr-trains

The patch disables resizing and rendering of CompositionWnd after 20 times rendering. With it, we could confirm window resizing effect without update of CompositionWnd.

Assignee: nobody → sotaro.ikeda.g
Assignee: sotaro.ikeda.g → nobody

With attachment 9038414 [details] [diff] [review], during resizing the Firefox window horizontally on its left hand side, I saw the Firefox window's right hand side flicker and wobble. It seemed happen when CompositionWnd's valid region exceeding parent windows' right hand side.

From it, it seems that parent windows clipped CompositionWnd's content, but it seemed not happen sync way with DirectComposition.

With attachment 9038421 [details] [diff] [review], I tested to run WebRender with DirectComposition in parent process. With it, during resizing the Firefox window horizontally on its left hand side, I still saw the Firefox window's right hand side flicker and wobble.

Then the problem happened just by enabling DirectComposition without using CompositionWnd.

With attachment 9038425 [details] [diff] [review], during resizing the Firefox window horizontally on its left hand side, I still saw the Firefox window's right hand side flicker and wobble even when there was no CompositionWnd and no resizing and rendering. It seemed happen when content exceeding windows' right hand side.

Attachment #9038425 - Attachment description: temporal patch - Disable GPU process and use WebRender in parent process and disable resizing and rendering after 20 times rendering → temporal patch - Disable GPU process and use WebRender in parent process and no resizing and no rendering after 20 times rendering

With attachment 9038673 [details] [diff] [review], during resizing the Firefox window horizontally on its left hand side, I did not see the Firefox window's right hand side flicker and wobble. But content was shrunk or enlarged horizontally. It seems to happen since DirectComposition was disabled.

Assignee: sotaro.ikeda.g → nobody
See Also: → 1579732
See Also: → 1617517
Severity: normal → S3
Blocks: wr-correctness
No longer blocks: stage-wr-next
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: