Closed Bug 1877153 Opened 1 year ago Closed 10 months ago

Canvas flicker on the profiler UI when a scrollbar appears in the timeline

Categories

(Core :: Graphics, defect)

Unspecified
macOS
defect

Tracking

()

RESOLVED FIXED
126 Branch
Tracking Status
firefox-esr115 --- unaffected
firefox122 --- unaffected
firefox123 --- unaffected
firefox124 --- fixed
firefox125 --- wontfix
firefox126 --- wontfix

People

(Reporter: florian, Assigned: bradwerth)

References

(Regression)

Details

(Keywords: regression)

Attachments

(1 file)

Here is a profile where the screenshot track shows the problem pretty well: https://share.firefox.dev/3vVRlaE

Steps to reproduce:

  1. Load a profile with few enough visible tracks that there's no vertical scrollbar on the timeline (eg. https://share.firefox.dev/49ebxD4). Ensure the last visible track is a memory track where the chart touches the bottom.
  2. Mouse the mouse around into and out of the area where the memory graph touches the bottom of the track.

Expected result:
When the mouse hovers a sample of the memory track that touches the bottom of the chart, a dot appears, and that makes the vertical scrollbar of the timeline appear. The dot and the (animated) scrollbar are the only things moving on screen.

Actual result:
All the canvas on the page become white for a split second.

The profile I was looking at when I noticed the bug is pretty large, and requires a large screen to see the bug, but a reduced version of it shows the bug too, even on the macbook's internal screen.

Set release status flags based on info from the regressing bug 1839425

:bradwerth, since you are the author of the regressor, bug 1839425, could you take a look? Also, could you set the severity field?

For more information, please visit BugBot documentation.

That's wild. I'm trying to reproduce but I'm not successful at getting the same results as you. In my case, through some careful pointer work near the intersection of the memory graph and the horizontal splitter, I can sometimes get the memory graph to flicker, sometimes get the bottom half of the page (with the Marker Chart) to flicker, but never the whole page. I'm also not using the Profiler enough to know what's a "normal" level of Canvas flicker -- I guess none at all.

Anyway, Bug 1839425 is a surprising regression candidate for this issue because it should only affect the type of layer created to host video. Is there any video content used in the Profiler? That seems odd.

One way to confirm this regression would be to set the "gfx.core-animation.specialize-video" pref to false. Does that fix the issue for you? If so, then it's definitely Bug 1839425, somehow.

Flags: needinfo?(bwerth) → needinfo?(florian)

I've confirmed that the Profiler is using video content. This is my Bug to fix. Wow!

Assignee: nobody → bwerth

These things are canvases so they should be BGRA buffers, not YCbCr or NV12 or anything like that. So I would suspect canvas to not benefit from a video layer.

Indeed all the horizontal graph images are processed by WebRender as external/native surfaces, passed to the macOS layers as TextureHost which NativeLayerCA treats as a video source. The change Bug 1839425 made was to always use a specialized video layer for video source. Florian, you probably would've see this issue before this regression if you were viewing the profiles in a fullscreen window, because the logic in NativeLayerCA was already using AVSampleBufferDisplayLayer for video in fullscreen windows.

Several solutions I can think of:

  1. Make WebRender not elevate these surfaces given that they are static images that won't benefit from being made external/native to the GPU. This would likely improve our tiling outcomes -- less layers sent by WR.
  2. Make WebRender reuse surfaces better in this situation. Nothing is changing size, just changing content, so why is the old surface being destroyed and a new one being created?
  3. Make NativeLayerCA detect these weird sort of TextureHost layers that don't get regular updates and prevent them from getting treated as video. This would be some kind of heuristic and therefore fallible.
  4. Make NativeLayerCA "warm up" the AVSampleBufferDisplayLayer with initial content so that there is no flicker when they are added to the screen.

Idea 4 is most within my abilities, and would be a fine solution, so that's what I'll try to accomplish.

Flags: needinfo?(florian)

Glenn, what's the value in WebRender treating BGRA surfaces as external/native? Is this just something we have to do because we can't composite them properly with other layers?

Flags: needinfo?(gwatson)

Non-external surfaces have to be copied into the texture cache. On macOS, our canvas surfaces are already backed by an IOSurface per canvas "frame" on macOS, so if we treat them as external / native we can put them on the screen without a copy.

(In reply to Brad Werth [:bradwerth] from comment #6)

  1. Make NativeLayerCA detect these weird sort of TextureHost layers that don't get regular updates and prevent them from getting treated as video. This would be some kind of heuristic and therefore fallible.

I think this would be the right solution. Conceptually we have three types of layers: "tiled surface" layers (bound and painted by webrender during rendering), "external BGRA" layers (for canvas), and "video" layers.

  1. Make NativeLayerCA "warm up" the AVSampleBufferDisplayLayer with initial content so that there is no flicker when they are added to the screen.

I wonder if we need to do something for video layers because there might still be a flickering problem with those.

(In reply to Markus Stange [:mstange] from comment #8)

  1. Make NativeLayerCA detect these weird sort of TextureHost layers that don't get regular updates and prevent them from getting treated as video. This would be some kind of heuristic and therefore fallible.

I think this would be the right solution. Conceptually we have three types of layers: "tiled surface" layers (bound and painted by webrender during rendering), "external BGRA" layers (for canvas), and "video" layers.

Great, then I will modify NativeLayerCA::IsVideoAndLocked and possibly NativeLayerCA::AttachExternalImage to check the format of external images and conclude that BGRA stuff is not video.

  1. Make NativeLayerCA "warm up" the AVSampleBufferDisplayLayer with initial content so that there is no flicker when they are added to the screen.

I wonder if we need to do something for video layers because there might still be a flickering problem with those.

It would be nice if I could figure it out because it would forestall any future problem where we re-generate AVSampleBufferDisplayLayer in place. We don't want to do that, re-generating same-size surfaces is wasteful, but we don't want to have flickering when and if we do that.

Flags: needinfo?(gwatson)

Easier steps to reproduce:

  1. Load https://share.firefox.dev/49ebxD4
  2. Press Cmd+Opt+K to open the Web Console.
  3. Make sure the devtools are displayed in "dock to bottom" mode.
  4. Focus the text box in the console so that you have a blinking cursor.

When the cursor flashes on and off, some canvases disappear or reappear. Profile with screenshots: https://share.firefox.dev/4bf2nHY

I find this a bit concerning because the invisible canvases remain invisible until the next composite, and not just until the WindowServer has caught up or something like that.

Pushed by bwerth@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/ed526ee3de75 Make NativeLayerCA check the colorspace of TextureHost to determine if it is video. r=mstange
Status: NEW → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 124 Branch

(In reply to Markus Stange [:mstange] from comment #10)

When the cursor flashes on and off, some canvases disappear or reappear.

This^ sort of canvas-disappearing-issue seems to have manifested during reftest test-runs as well -- see bug 1877305, which appears to have the same regression range per bug 1877305 comment 19.

Given the similarity, I'm hoping that it was fixed by the patch that landed here; I'm waiting on some treeherder backfill-tasks to confirm.

Duplicate of this bug: 1877305
Flags: qe-verify+
Backout by sstanca@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/a9db5ebd04a7 Backed out changeset ed526ee3de75 as a follow-up to 1839425 for causing os build bustages. CLOSED TREE
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Target Milestone: 124 Branch → ---
Pushed by bwerth@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/e06d20ad693a Make NativeLayerCA check the colorspace of TextureHost to determine if it is video. r=mstange
Status: REOPENED → RESOLVED
Closed: 1 year ago10 months ago
Resolution: --- → FIXED
Target Milestone: --- → 126 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: