Closed Bug 1494403 (blob-recoord) Opened 6 years ago Closed 5 years ago

blob image re-coordination

Categories

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

64 Branch
defect

Tracking

()

RESOLVED FIXED
mozilla65
Tracking Status
firefox64 --- wontfix
firefox65 --- fixed

People

(Reporter: jrmuizel, Assigned: nical)

References

(Depends on 1 open bug, Blocks 3 open bugs)

Details

(Whiteboard: [wr-q4])

Attachments

(3 files, 7 obsolete files)

47 bytes, text/x-phabricator-request
Details | Review
93.49 KB, patch
Details | Diff | Splinter Review
47 bytes, text/x-phabricator-request
Details | Review
We want to adjust some of the coordinate spaces in blob images to better align with what Gecko needs and to make it so that scrolling and resizing of the blob images works well.
Blocks: 1429930
Blocks: 1493466
Blocks: 1477369
No longer blocks: 1477369
Blocks: 1494408
Priority: -- → P2
Summary: [meta] blob image re-coordination → blob image re-coordination
Here's the plan:

At the moment, blob images only have a size. They are sized to the bounds of the nsDisplaySVGWrapper display item. (0, 0) inside the blob's coordinate space is at the top left corner of the nsDisplaySVGWrapper's bounds. This means that, if the nsDisplaySVGWrapper's bounds expand / such that the origin of the bounds rectangle changes, this affects the coordinate space of the blob. Any items inside the blob will now be treated as having "moved" because their coordinates relative to the blob's origin have changed. This causes unnecessary invalidations in many legitimate cases. For example, when scrolling up, display items can get added at the top of a blob, which affects the wrapper's bounds.

We want to change this such that (0, 0) inside the blob coordinate space refers to (0, 0) in SVG user space. SVG elements create reference frames now, and that reference frame's position is the (0, 0) that we want here.

In order to do this, we need to give the blob image an origin in this space. We still want to size the blob image to the bounds of the nsDisplaySVGWrapper item. So instead of giving the blob image just a "size", we need to give it a "rect". This rectangle describes the area that is covered by the blob image in blob image space. And we need to update Gecko to set coordinates on the blob content items that are relative to (0, 0) instead of being relative to the blob's bounds. This part should be pure code removal.

Then we need to make sure that resizing the blob does not invalidate unchanged pixels in the middle of the image. This means 1) ensuring that Gecko doesn't send unnecessarily large invalid rects with its updates and 2) teaching WebRender not to discard tiles / pixels for parts of a blob image that haven't changed even when the blob's rect has changed.

We might also need to take a look at how blob merging handles this case.
Priority: P2 → P3
Blocks: 1391838
Blocks: 1425871
Assignee: nobody → a.beingessner
Priority: P3 → P2
Blocks: 1494924
Blocks: 1470219
Blocks: 1477371
Blocks: 1477374
Alias: blob-re-coord
Blocks: 1478125
Blocks: 1484863
Blocks: 1477369
Blocks: 1494173
Previously dirty rects were set up in a subtle way where early in the
pipeline None is used to mean "no information" and therefore "all clean",
but then later on is used to mean "all dirty" on the assumption that if
a texture is still being handled, some dirty information must have been
sent. None is therefore used by the internals as a way to signal
things like missing cache entries without actually bothering to look up 
the dimensions of the image (note that "clean" can always be expressed
without knowing dimensions, as it is always the same empty rect).

I change the system to just consistently use a custom enum that has
AllDirty and SomeDirty(empty_rect) to represent these two states. As
a result the code seems much easier to understand.

This is WIP because I probably want to make the dirty rect signed so
that it can be in the same space as the visible rect introduced in the
following commit. Also I probably need to rework how dirty rects are
passed for tiles, for similar reasons.
Assignee: a.beingessner → nical.bugzilla
This commit contains the Gecko-side changes from WebRender PR#3277:
 - Dedicated DirtyRect type.
 - Separate the blob image APIs from regular image ones.
Try push with the Gecko and WebRender API changes around blob images and dirty rects: https://treeherder.mozilla.org/#/jobs?repo=try&revision=c468b1b643bb7fb6fcebccb0dc8ea4001c50f3d6
Pushed by kgupta@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/df30b0f614c9
Separate the Blob related apis. r=jrmuizel
https://hg.mozilla.org/mozilla-central/rev/df30b0f614c9
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla65
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Depends on: 1510544
I'm working on rebasing D9560/"WIP recoordination, still need to rework wr image cache to handle visible rect properly."
I have the gecko side rebased and partially debugged. I'm running into an issue with code like:
  gfxRect maskSurfaceRect = context->GetClipExtents(gfxContext::eDeviceSpace);
getting confused about what the extents of the draw target are. I'll need to think more about how to solve that.
Depends on: 1513772
Attached patch Gecko side v2 (obsolete) — — Splinter Review
This version of the patch seems to basically work and the most egregious test failures are fixed. 

https://treeherder.mozilla.org/#/jobs?repo=try&revision=47b2af11447879688df9e19c3abfd6f0dca68c07&selectedJob=217592705
Attachment #9019430 - Attachment is obsolete: true
(In reply to Jeff Muizelaar [:jrmuizel] from comment #9)
> I have the gecko side rebased and partially debugged. I'm running into an
> issue with code like:
>   gfxRect maskSurfaceRect =
> context->GetClipExtents(gfxContext::eDeviceSpace);
> getting confused about what the extents of the draw target are. I'll need to
> think more about how to solve that.

The best solution seems to be to reuse the SetDeviceOffset support gfxContext.
The remaining interesting failures are:
 /css/CSS2/inline-svg-intrinsic-size-100-percent-1.html
 layout/reftests/image-element/element-paint-native-widget.html
 layout/reftests/svg/pattern-big-image.html
We also seem to be hitting Hit 'MOZ_CRASH(Manual eviction requires cleanup) at gfx/wr/webrender/src/resource_cache.rs:219'
> We also seem to be hitting Hit 'MOZ_CRASH(Manual eviction requires cleanup) at gfx/wr/webrender/src/resource_cache.rs:219'

I got this one to reproduce in rr. Looking into it.
> I got this one to reproduce in rr. Looking into it.

Nevermind, the one I have in rr is during rawtests and the issue was that some of the tests weren't cleaning the blob image keys themselves (cf. https://github.com/servo/webrender/pull/3470), so it wasn't an issue with webrender's resource cache. In that try run the blob image key leak is likely happening on the gecko side.
Priority: P2 → P3
Attached patch Gecko side v3 — — Splinter Review
Attachment #9032073 - Attachment is obsolete: true
Priority: P3 → P4
Pushed by nsilva@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/b2812c159321
Support arbitrary tiling origins and negative tile offsets in the tile decomposition algorithm. r=kvark
Status: REOPENED → RESOLVED
Closed: 6 years ago5 years ago
Resolution: --- → FIXED
Status: RESOLVED → REOPENED
Keywords: leave-open
Resolution: FIXED → ---
Blocks: wr-68
No longer blocks: stage-wr-trains
Priority: P4 → P2

It looks like things were broken somewhat by the "Use CreateClippedDrawTarget more." from bug 1495170

Depends on: 1539702
Whiteboard: [wr-q2][wr-june]
Depends on: wr-69
No longer depends on: 1510544
Blocks: wr-69
No longer depends on: wr-69

Here's a version rebased on top of central/CreateClippedDrawTarget https://treeherder.mozilla.org/#/jobs?repo=try&revision=958792c35edd196bfe1ecb4343b06776af0c12d3

No longer blocks: wr-68

Here's the latest reftest run. I believe the failures are probably fuzzable.
https://treeherder.mozilla.org/#/jobs?repo=try&revision=d25df7f130dbd2e3ca4c6e6dd9efb790f8367155

Depends on: 1561097
Depends on: 1561743

I plan on breaking this up into three main parts to aid review and help with the bisection of any regressions:

  1. Remove the top-left offset from the recording and apply it during playback: https://treeherder.mozilla.org/#/jobs?repo=try&revision=f9a1ecc45af3a1e549420effe5d73278c7ba86a1
  2. Remove the top-left offset from the bounds in the index: https://treeherder.mozilla.org/#/jobs?repo=try&revision=48e85a3476c6ae0c5ec76ee8a73c7d0b62e78028
  3. Switch to orienting things around the visible rect instead of the item bounds. https://treeherder.mozilla.org/#/jobs?repo=try&revision=bfe0937ace60f44f827f793817553194a9a165c9&selectedJob=253943326

The final results seems to pass tests, the earlier pieces still need some work.

Blocks: wr-70
No longer blocks: wr-69
Depends on: 1563770
Alias: blob-re-coord → blob-recoord
Whiteboard: [wr-q2][wr-june] → [wr-q3][wr-july]
Depends on: 1564655
Depends on: 1563775
Depends on: 1565580
Depends on: 1565904
Attachment #9066742 - Attachment is obsolete: true
Attachment #9065695 - Attachment is obsolete: true
Attachment #9066741 - Attachment is obsolete: true
Attachment #9067093 - Attachment is obsolete: true
Depends on: 1568227
Depends on: 1570331
Depends on: 1570399
Depends on: 1570435
Whiteboard: [wr-q3][wr-july] → [wr-q3][wr-sept]
Blocks: 1574199
Depends on: 1570081
Blocks: wr-71
No longer blocks: wr-70
Depends on: 1581953
Depends on: 1580062
Whiteboard: [wr-q3][wr-sept] → [wr-q4]

This is done.

Status: REOPENED → RESOLVED
Closed: 5 years ago5 years ago
Resolution: --- → FIXED
Attachment #9019430 - Attachment is obsolete: false
Attachment #9019430 - Attachment is obsolete: true
Attachment #9019429 - Attachment is obsolete: true
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: