Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with Flutter 3.19 iOS impeller optimization for BackdropFilter #360

Closed
mikeesouth opened this issue Feb 25, 2024 · 5 comments
Closed
Labels
bug Something isn't working

Comments

@mikeesouth
Copy link

mikeesouth commented Feb 25, 2024

Description

Flutter 3.19 introduced new optimizations for BackdropFilter when using Impeller (currently only on iOS). This new optimization does not work correctly for Rive assets with two (or more) clipping masks that affect the same element. This is the result of my detective work but I assume that there is a better and more logical explanation to why this happens :) I have this issue with one of my main Rive assets so that's why I started to debug and found that removing the secondary clipping mask solved the issue.

Ok, so a BackdropFilter can blur the background and maybe also dim the backgrounds content with 50% opacity black color or so. It's commonly used with modals. When having a Rive asset in the background, the expected result is for that Rive asset to also blurred and dimmed - even if it's animated. This works correctly in Flutter 3.16 for all files that I've tested. In Flutter 3.19, it works for all files except if the Rive artboard contains two (or more) clipping masks - then that Rive asset is displayed without blur and without dim from the backdrop color - it is just as if the Rive animation was drawn on top of the BackdropFilter instead of under it. I also tested with Flutter 3.19.1 and it has the same issue.

Steps To Reproduce

Here is a repo that reproduces the error: https://github.com/mikeesouth/rive_mask_backdrop_bug

Steps to reproduce the behavior:

  1. Create a Rive asset with three shapes, e.g. square, star, star
  2. Select the square and add the stars as clipping masks (two masks)
  3. Export the file, load it into Flutter 3.19
  4. Add a BackdropFilter on top of the Rive asset
  5. See error ⚠️: The backdrop filter does not affect the Rive asset

Source .riv/.rev file

I've attached two files:

  • test1.riv only has one clipping mask and it works
  • test2.rive has two clipping masks and it does not work correctly with the BackdropFilter in Flutter 3.19
    rive-test-files.zip

Expected behavior

I expect the Rive asset to be blurred and dimmed by the BackDropfilter, even if the file contains two or more clipping masks.

Screenshots

First a screenshot of how it looks, note that the third image in the top isn't blurred or dimmed.
Rive-BackdropFilter-blur_issue

Here is a very simple screenshot from the Rive editor describing how I created the second mask. The issue occurs if the masks is set on the same entity or in nested entities (in this screenshot, the second mask is created deeper in the structure than the first mask).
rive_mask_config

Device & Versions (please complete the following information)

  • Device: iOS Simulator, iPad physical device
  • OS: iOS 17
  • Flutter Version:
Flutter 3.19.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision abb292a07e (5 days ago) • 2024-02-20 14:35:05 -0800
Engine • revision 04817c99c9
Tools • Dart 3.3.0 • DevTools 2.31.1

Additional context

I'm not sure if this is a problem with rive-flutter or with the new optimization in Flutter 3.19. Maybe I should post this issue on the flutter github too? I haven't looked too much into the details of these optimizations but I guess that flutter/engine#47808 and flutter/engine#47397 are related.

This bug can be tested in this repo: https://github.com/mikeesouth/rive_mask_backdrop_bug

@mikeesouth mikeesouth added the bug Something isn't working label Feb 25, 2024
@HayesGordon
Copy link
Contributor

Hi @mikeesouth, thanks for the detailed report!

This does seem like a Flutter/Impeller issue and will need to be reported to the Flutter team. Especially if it used to work on 3.16

Would you be willing to make a new issue on the Flutter repo, and link to this one?

@mikeesouth
Copy link
Author

@HayesGordon thanks!
I created an issue: flutter/flutter#144211

@HayesGordon
Copy link
Contributor

HayesGordon commented Feb 27, 2024

Great! I see they have already been able to repro

edit: spelling

@orestesgaolin
Copy link

orestesgaolin commented May 6, 2024

The Flutter issue has been closed, and 3.19.4 seems to include this fix. Can you verify it works again as expected?

@mikeesouth
Copy link
Author

Sorry for the late response but yes - this works as expected now in 3.22.1 (latest stable). I didn't have time to test in 3.19.4 but I assume that it works there too. Thanks for handling this swiftly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants