Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upStore a queue of rasterized blobs instead for non-tiled images. #3079
Conversation
|
This PR might be easier to understand by reading the commits individually. It looks kinda complicated and I'm sorry about that. The alternative was in my opinion also complicated and more invasive. |
|
Looks good in general (and good job discovering the race condition!). I left a few questions below. Also needs a try push.
webrender/src/resource_cache.rs, line 610 at r1 (raw file):
shouldn't this depend on the webrender/src/resource_cache.rs, line 615 at r2 (raw file):
why aren't we just matching? webrender/src/resource_cache.rs, line 1425 at r2 (raw file):
can we just keep it in webrender/src/resource_cache.rs, line 1447 at r2 (raw file):
can probably skip the webrender/src/resource_cache.rs, line 1113 at r3 (raw file):
shouldn't need |
webrender/src/resource_cache.rs, line 610 at r1 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
This is just a placeholder, we have to create the entry with something and below we populate the thing (making it non-tiled if need be). webrender/src/resource_cache.rs, line 615 at r2 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
Here we first look at whether the thing is non-tiled and make it tiled. Then as a second step we push the tiles. if we were to try to do it on a single match we would have to at the same time get a mutable handle on the tiles in the ::Tiled arm and be able to overwrite the whole thing on the other arm, and have both arms push the tiles. webrender/src/resource_cache.rs, line 1425 at r2 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
Is that really simpler? having a smallvec on the stack feels like less work to me since we only use it here and that way we don't need to think about whether state can accidentally persist or anything. webrender/src/resource_cache.rs, line 1447 at r2 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
Ah yes indeed. |
|
This try push has the patches from this PR plus the backed out ones that prevent redundant frame building |
webrender/src/resource_cache.rs, line 610 at r1 (raw file): Previously, nical (Nicolas Silva) wrote…
I see. A comment would help :) webrender/src/resource_cache.rs, line 1425 at r2 (raw file): Previously, nical (Nicolas Silva) wrote…
it's a simple guarantee of no allocations in place (on regular basis, of course), where webrender/src/resource_cache.rs, line 1447 at r2 (raw file): Previously, nical (Nicolas Silva) wrote…
still there webrender/src/resource_cache.rs, line 1113 at r3 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
ping |
|
Yep I haven't addressed the nits yet, coming soon. |
|
My general concern about This particular case may not be that important, I'm just expressing the general idea. |
|
This is specific case is independent of scene complexity and is only requiring the allocation in rare cases of unfortunate timings. I see where you are coming from but in this case I believe SmallVec is sensible.
|
webrender/src/resource_cache.rs, line 1447 at r2 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
Done. webrender/src/resource_cache.rs, line 1113 at r3 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
Done. |
|
|
shipit |
|
|
Store a queue of rasterized blobs instead for non-tiled images. This fixes a race-condition that happens if we don't upload rasterized blobs right after scene building which blocks the work on avoiding redundant frame builds. The idea is that instead of keeping a single rasterized blob per image, we store a queue which lets us have several partial updates of a blob in flight (previously the second update would clobber the first and miss the updated area of the first update). To prevent the queue from growing indefinitely, we make it so that older elements are discarded if a newer one covers them, and re-rasterize everything if the queue gets big to put it back to a single update. I expect that most of the time for visible items the queue will stay at 1 (or rarely 2) updates even if the blob is updating constantly because we tend to render at least as often as we build scenes. For items that are off-screen and thus not getting uploaded, the queue will alternate between 1, 2 and 3 elements, and we'll force the rasterization of the whole image each time the queue gets to 3 to force the queue back to 1 element. The case of animated off-screen blobs is pretty bad because they generate rasterization constantly and don't end up on screen, but that's already the case today. We could (as a followup) try to just discard the elements of the queue when it gets big (3 elements or more) and skip rasterization of the blob image until we see it. This means the next time we see it we'll risk jank since it will trigger the synchronous rasterization during frame building, but at least we'd have avoided rasterizing the blobs during the time it was animating off-screen. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/3079) <!-- Reviewable:end -->
|
|
Temporarily revert #3079 for a crash workaround. <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/3108) <!-- Reviewable:end -->
Store a queue of rasterized blobs instead for non-tiled images (take two) The 3 commits from #3079 which were reverted in #3108 plus a commit that fixes the crash that motivated the backout. Bugzilla entry: https://bugzilla.mozilla.org/show_bug.cgi?id=1493177 In the texture cache we have an automatic and a manual eviction policy. The manual eviction policy ensures blob images don't get automatically evicted from the cache which could otherwise race with the asynchronous rasterization. The Texture cache was missing a tiny piece of code to ensure the eviction policy was respected in for shared cache entries (it does work for normal cache entries). I bet border images make uses of these shared entries. While scrolling the image eventually gets discarded and next time we see it we request the image. The problem is that when we decide whether a blob image is missing, we only look at whether there is an entry in the rasterized_blob_image map, but we don't check whether that entry contains any actual data to upload in its queue. Before the regressing commit, the bug would occur without crashing, but we wouldn't necessary upload all of the image (only the last available dirty region). With that commit we end up requesting something we think we have but don't have and later panic with an empty handed upload request. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/3111) <!-- Reviewable:end -->
Avoid redundant frame builds (take two). #3052 rebased with fixes from #3079. The [try push](https://treeherder.mozilla.org/#/jobs?repo=try&revision=8f436bfb2b982214738e512042a460c73bc96432) of the version before rebase looked good but I'll make another one to be on the safe side. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/3092) <!-- Reviewable:end -->
nical commentedSep 18, 2018
•
edited by larsbergstrom
This fixes a race-condition that happens if we don't upload rasterized blobs right after scene building which blocks the work on avoiding redundant frame builds.
The idea is that instead of keeping a single rasterized blob per image, we store a queue which lets us have several partial updates of a blob in flight (previously the second update would clobber the first and miss the updated area of the first update).
To prevent the queue from growing indefinitely, we make it so that older elements are discarded if a newer one covers them, and re-rasterize everything if the queue gets big to put it back to a single update.
I expect that most of the time for visible items the queue will stay at 1 (or rarely 2) updates even if the blob is updating constantly because we tend to render at least as often as we build scenes.
For items that are off-screen and thus not getting uploaded, the queue will alternate between 1, 2 and 3 elements, and we'll force the rasterization of the whole image each time the queue gets to 3 to force the queue back to 1 element.
The case of animated off-screen blobs is pretty bad because they generate rasterization constantly and don't end up on screen, but that's already the case today.
We could (as a followup) try to just discard the elements of the queue when it gets big (3 elements or more) and skip rasterization of the blob image until we see it.
This means the next time we see it we'll risk jank since it will trigger the synchronous rasterization during frame building, but at least we'd have avoided rasterizing the blobs during the time it was animating off-screen.
This change is