Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@knopp
Copy link
Member

@knopp knopp commented Dec 22, 2021

Fixes flutter/flutter#95211

If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See testing the engine for instructions on
    writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Copy link
Contributor

@flar flar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

I mentioned elsewhere that there are a number of places in the bounds calculation code that introduce the type of inaccuracy mentioned here, but if we can address at least one operation slightly more accurately with a small amount of code then that is fine.

@flar
Copy link
Contributor

flar commented Dec 22, 2021

I just had a thought, though, that might indicate that this approach may be incorrect. It depends on how the filter is applied. If it is applied to the source content and then transformed then the roundOut is actually required in order to compute accurate bounds because content bounds that touch part of a pixel put a color into that entire pixel and you must take the bounds of the pixel data to compute the impact of the filter - in other words you must roundOut because that accurately takes the coverage of the border pixels into account.

In this case, you are computing the area of the source that contributes to the area under the backdrop content. In that case the backdrop content may extend from 0.5, 0.5 to 10.5, 10.5. In order to render that correctly, you need to include any pixel that contributes to the pixels hit by the 0.5 and the 10.5 - which means any pixel that contributes to 0,0 and 10.9999, 10.9999. So, the roundOut may actually be more "correct"?

Copy link
Contributor

@flar flar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a thought that I left in the PR comments about whether or not the roundOut in the "non optimal" case actually better reflects the operation we are modeling here. I'm marking my review as "Request changes" until we evaluate that consideration.

@knopp
Copy link
Member Author

knopp commented Dec 22, 2021

I definitely might be missing something here, but as far as I can tell the filter is sampling the pixels from the underlying frame-buffer (which is in device space). So any rounding that needs to be done to get actual affected pixels should be done in device space (i.e. after transform).

So do I think this approach is correct. Whether it's worth the extra branch is another question (especially after seeing the cullrect of SkPicture).

@flar
Copy link
Contributor

flar commented Dec 22, 2021

I look at it this way. The bounds start as the theoretical bounds for the content of the backdrop filter. They identify the pixels that will be modified.

The background of those pixels came from up to N pixels away - from the edges of those pixels (i.e. not from the edges of the theoretical bounds of the content).

So, to determine what of the background needs to be rendered, you must determine which background pixels contributed to any part of the pixels that will be touched by the inner content.

To compute this:

  • find the bounds of the inner content (which is given here)
  • find the bounds of the pixels that will be overwritten (i.e. roundOut)
  • find the bounds of any pixels that contribute to any part of those bg pixels (filter bounds of integer bounds of the bg pixels)

After having written this, I realize that this is exactly what the typical branch of the code is doing, so ignore my comments.

Copy link
Contributor

@flar flar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - my previous comments about a potential problem were off-base.

@knopp
Copy link
Member Author

knopp commented Dec 22, 2021

@flar, I pushed another variant where I instead of scaling the filter I pass the transform to filterBounds. It doesn't choke on perspective transform like makeWithLocalMatrix would and existing diff tests pass (they include scale layer in hierarchy so we know if filter bounds are properly scaled). I'll give this some more thought but it seems like this might be the way to go.

@knopp
Copy link
Member Author

knopp commented Dec 22, 2021

Looking at SkBlurImageFilter::onFilterNodeBounds for example it uses the specified ctm to scale sigma which seems like the thing we'd want it to do.

@knopp knopp merged commit f8a398f into flutter:main Jan 4, 2022
@knopp knopp deleted the bug_95211 branch January 4, 2022 22:17
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 5, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 5, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 6, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 6, 2022
zanderso pushed a commit to flutter/flutter that referenced this pull request Jan 6, 2022
* 9481a79 Roll Skia from 45f64bd52835 to 6bebf036a502 (2 revisions) (flutter/engine#30659)

* fb4a86c Roll Fuchsia Mac SDK from RyUwCnr_M... to vpa6vKu7U... (flutter/engine#30661)

* 154bd96 Roll Skia from 6bebf036a502 to 5726d457cf15 (1 revision) (flutter/engine#30665)

* ba23c6c Roll Skia from 5726d457cf15 to 61d0fbbca795 (5 revisions) (flutter/engine#30673)

* e749ba3 Impl and test (flutter/engine#30488)

* a78103c Removed "UiThread" annotation from MethodChannel#Result. (flutter/engine#30671)

* f8a398f Fix crash in BackdropFilterLayer::Diff (flutter/engine#30460)

* a6a856f Only provide frame damage to rasterizer if partial repaint is enabled (flutter/engine#30461)

* 3a667ab Roll Fuchsia Mac SDK from vpa6vKu7U... to Al-HXHXyQ... (flutter/engine#30677)

* 830abeb [web] roll CanvasKit 0.32.0; fix frame order in animated images (flutter/engine#30680)

* c726121 Add a new display_list_benchmarks test suite (flutter/engine#30678)

* f181c4d [web] flip browser image codec flag to opt-out (flutter/engine#30681)

* 436a346 Remove the ios_tools Chromium-style dependency (flutter/engine#30538)

* 3f63998 [web] bring libraries.yaml/libraries.json up to date (flutter/engine#30467)

* ab1e8f5 Roll Skia from 61d0fbbca795 to 4981c921c6d7 (1 revision) (flutter/engine#30684)

* 8e4124b Roll Skia from 4981c921c6d7 to d7771857e9e2 (2 revisions) (flutter/engine#30685)

* acb60b4 Roll Fuchsia Mac SDK from Al-HXHXyQ... to G04Sc3__F... (flutter/engine#30687)

* 0176295 [Win32, Keyboard] TextInputPlugin is no longer a KeyboardHandlerBase (flutter/engine#30456)

* bcb4b35 Roll Skia from d7771857e9e2 to ec2e8f11b97a (1 revision) (flutter/engine#30688)

* e09f8d1 Roll Dart SDK from 1697706df708 to ab5047720a9e (5 revisions) (flutter/engine#30690)

* d60c816 Roll Dart SDK from 1697706df708 to f59531cc2973 (10 revisions) (flutter/engine#30691)

* 417042c GN targets for generating release artifacts (flutter/engine#30679)

* 7f31015 Roll Skia from ec2e8f11b97a to 84d6cf9b5b76 (7 revisions) (flutter/engine#30693)

* fed9e0b Roll Skia from 84d6cf9b5b76 to 88c5af7ecd72 (3 revisions) (flutter/engine#30695)

* 36eafae [fuchsia][shader warmup] fix for fxbug.dev/90387 (flutter/engine#30482)

* 0c036a7 Revert "Only provide frame damage to rasterizer if partial repaint is enabled (#30461)" (flutter/engine#30696)

* 8498779 [fuchsia] Fix failing SDK roll. (flutter/engine#30675)
@TetrixGauss
Copy link

Hello all! After i updated to the latest version of Flutter, i faced the above problem! Is there something i could do? some temporary fix ?

@flar
Copy link
Contributor

flar commented Feb 9, 2022

@TetrixGauss if you could be more specific on the version you discovered this on, the fix is currently being considered to be cherry picked for the stable release so it would be good to know if you found this on the stable branch or the ToT development branch.

Otherwise, the fix looks like it should be good for cherry-picking to the latest release train.

@knopp
Copy link
Member Author

knopp commented Feb 9, 2022

It should be cherry-picked for 2.10.1.

@itsjustkevin
Copy link
Contributor

Added to the queue for 2.10.2.

@TetrixGauss
Copy link

TetrixGauss commented Feb 10, 2022

@TetrixGauss if you could be more specific on the version you discovered this on, the fix is currently being considered to be cherry picked for the stable release so it would be good to know if you found this on the stable branch or the ToT development branch.

Otherwise, the fix looks like it should be good for cherry-picking to the latest release train.

@flar i just did flutter upgrade in stable channel and in version 2.10.0 and i found that bug! i dont know if that helps..

itsjustkevin pushed a commit to itsjustkevin/engine that referenced this pull request Feb 17, 2022
* Fix crash in BackdropFilterLayer::Diff

* Pass context transform to filterBounds instead of scaling the filter
itsjustkevin added a commit that referenced this pull request Feb 18, 2022
* Fix crash in BackdropFilterLayer::Diff (#30460)

* Fix crash in BackdropFilterLayer::Diff

* Pass context transform to filterBounds instead of scaling the filter

* Disable building examples by default (#30946)

This should be paired with a recipe change to enable building the example on CI that I'll prepare shortly.

* Detach from GL context before attaching (#31390)

* 'add branch flutter-2.8-candidate.16 to enabled_branches in .ci.yaml'

* remove ref to branch

* add junit dependency to gradle.build

Co-authored-by: Matej Knopp <[email protected]>
Co-authored-by: Zachary Anderson <[email protected]>
Co-authored-by: Emmanuel Garcia <[email protected]>
Co-authored-by: Kevin Chisholm <[email protected]>
@TetrixGauss
Copy link

Hello all! does the 2.10.2 has the fix for the backdropFillter bug ?

@TetrixGauss
Copy link

Hello all! does the 2.10.2 has the fix for the backdropFillter bug ?

It's fixed!!! Thank you guys!!!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Transform animation with BackdropFilter is causing a crash (null pointer dereference)

4 participants