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

Support ShaderMask on web #44152

Closed
justinmc opened this issue Nov 5, 2019 · 30 comments
Closed

Support ShaderMask on web #44152

justinmc opened this issue Nov 5, 2019 · 30 comments
Assignees
Labels
c: new feature Nothing broken; request for a new capability c: rendering UI glitches reported at the engine/skia rendering level customer: crowd Affects or could affect many people, though not necessarily a specific customer. customer: webeap e: web_canvaskit CanvasKit (a.k.a. Skia-on-WebGL) rendering backend for Web e: web_html HTML rendering backend for Web engine flutter/engine repository. See also e: labels. P2 Important issues not at the top of the work list platform-web Web applications specifically

Comments

@justinmc
Copy link
Contributor

justinmc commented Nov 5, 2019

I discovered in the CupertinoContextMenu PR that Flutter Web does not support the ShaderMask widget right now. Running tests that created this widget caused assertion unimplemented errors for pushShaderMask. See a Cirrus run.

We should implement support for ShaderMask and remove the conditional skipTest: isBrowser in context_menu_test.dart.

@justinmc justinmc added f: cupertino flutter/packages/flutter/cupertino repository platform-web Web applications specifically labels Nov 5, 2019
@yjbanov yjbanov added this to the Near-term Goals milestone Nov 5, 2019
@yjbanov yjbanov added the engine flutter/engine repository. See also e: labels. label Nov 5, 2019
@eyjiang
Copy link

eyjiang commented Nov 24, 2019

Hi! Could I try taking this task? Thanks!

@Hixie Hixie added the framework flutter/packages/flutter repository. See also f: labels. label Nov 26, 2019
@justinmc
Copy link
Contributor Author

justinmc commented Dec 4, 2019

@eyjiang Yeah please do! Sorry for the delayed response.

@yjbanov Do you have any more context for implementing ShaderMask on web?

@diegoveloper
Copy link
Member

Check this sample I created: https://dartpad.dev/5536c9d19d9ea15874416dc4835ba06d , it works fine in mobile.
If you check this condition child: true ? ShaderMask to false it will work.

@yjbanov
Copy link
Contributor

yjbanov commented Jan 15, 2020

Sorry for late response. TBH I've no idea what shader mask does, so I cannot provide much context. I imagine the change would be similar to flutter/engine@3381392. For the CanvasKit backend it's likely a matter of forwarding the right method call. For the HTML backend the trick is to find the HTML/canvas equivalent of this effect.

@Dibitybopty
Copy link

Anything new on supporting ShaderMask for Web? Looks like a great widget to use.

@BrutalCoding
Copy link

Still broken as of now with the latest beta. Getting the following error 'Another exception was thrown: PersistedOffset: is in an unexpected state.' when using the ShaderMask() widget. The properties my widget has are just the shaderCallback and a child. Returning null or a LinearGradient in the shaderCallback makes no difference for the error.

Flutter (Channel beta, v1.17.0-3.4.pre, on Mac OS X 10.15.4 19E287, locale en-GB)
• Flutter version 1.17.0-3.4.pre at /Users/danielbreedeveld/Development/Tools/flutter
• Framework revision e6b34c2 (2 days ago), 2020-05-02 11:39:18 -0700
• Engine revision 540786dd51
• Dart version 2.8.1

@kf6gpe kf6gpe added the P1 High-priority issues at the top of the work list label May 29, 2020
@kf6gpe kf6gpe modified the milestone: Near-term Goals Jun 1, 2020
@yjbanov yjbanov added P2 Important issues not at the top of the work list and removed P1 High-priority issues at the top of the work list labels Jun 16, 2020
@pravnviji
Copy link

I'm new to flutter development. is ShaderMask is supported in 1.19.0-4.2.pre- channel beta ?

@justinmc
Copy link
Contributor Author

justinmc commented Jul 6, 2020

ShaderMask is not supported on web yet, but it is supported on other platforms. If someone adds support on web, this issue will be updated.

@yjbanov yjbanov added e: web_html HTML rendering backend for Web c: rendering UI glitches reported at the engine/skia rendering level and removed f: cupertino flutter/packages/flutter/cupertino repository framework flutter/packages/flutter repository. See also f: labels. labels Jan 28, 2021
@ferhatb ferhatb self-assigned this Feb 10, 2021
@ferhatb
Copy link
Contributor

ferhatb commented Feb 12, 2021

@diegoveloper , thanks for patience on this issue. We have a fix, tested with your DartPad sample. It should land shortly in master. Great sample btw.

@mzdm
Copy link
Contributor

mzdm commented Feb 12, 2021

@ferhatb Nice! I wonder whether it will make hnvn/flutter_shimmer#25 shimmer package workable (on web)?

@Niggelgame
Copy link

@ferhatb Nice! I wonder whether it will make hnvn/flutter_shimmer#25 shimmer package workable (on web)?

Probably, since the only problem there was ShaderMask

@justinmc
Copy link
Contributor Author

Closing this as it seems from #52967 (comment) and @ferhatb's comment above that ShaderMask is now supported on web. Let me know if that's not right!

@arvind-iyer-2001
Copy link

I'm still facing errors with ShaderMasks on Flutter Web Builds. Has any fix arrived for this now? It seems to work fine on Emulators and Physical Devices but not on the Web~. Even Windows Desktop Flutter App seems to work.

@ferhatb
Copy link
Contributor

ferhatb commented Apr 27, 2021

@arvind-iyer-2001 please file a new issue with a small sample to reproduce. Some fixes may have only landed on master channel and propagating through dev->beta->stable releases.

@vargascarlitos
Copy link

It does not work for me for web applications

pd. In my work they only let me use the stable branch :(

Container(
                        color: background_light_3,
                        height: 8,
                        child: ShaderMask(
                          blendMode: BlendMode.srcATop,
                          shaderCallback: (rect) {
                            return gradient.createShader(rect);
                          },
                          child: LinearProgressIndicator(
                            value: value,
                            minHeight: 8,
                            backgroundColor: Colors.transparent,
                            valueColor: AlwaysStoppedAnimation<Color>(background_light),
                          ),
                        ),
                      ),
`Flutter 2.0.6 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 1d9032c7e1 (hace 4 días) • 2021-04-29 17:37:58 -0700
Engine • revision 05e680e202
Tools • Dart 2.12.3

Running flutter doctor...
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.0.6, on macOS 11.2.3 20D91 darwin-x64, locale es-419)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.0)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.1)
[✓] VS Code (version 1.42.1)
[✓] Connected device (1 available)
`
  • [══╡ EXCEPTION CAUGHT BY SCHEDULER LIBRARY ╞═════════════════════════════════════════════════════════
    js_primitives.dart:30 The following UnimplementedError was thrown during a scheduler callback:
    js_primitives.dart:30 UnimplementedError
    js_primitives.dart:30
    js_primitives.dart:30 When the exception was thrown, this was the stack:
    js_primitives.dart:30 dart-sdk/lib/internal/js_dev_runtime/private/ddc_runtime/errors.dart 236:49 throw
    js_primitives.dart:30 lib/_engine/engine/html/scene_builder.dart 231:5 pushShaderMask
    js_primitives.dart:30 packages/flutter/src/rendering/layer.dart.js 2261:34 addToScene
    js_primitives.dart:30 packages/flutter/src/rendering/layer.dart.js 891:12 [_addToSceneWithRetainedRendering]
    js_primitives.dart:30 packages/flutter/src/rendering/layer.dart.js 1515:50 addChildrenToScene
    js_primitives.dart:30 packages/flutter/src/rendering/layer.dart.js 2431:12 addToScene
    js_primitives.dart:30 packages/flutter/src/rendering/layer.dart.js 891:12 [_addToSceneWithRetainedRendering]
    js_primitives.dart:30 packages/flutter/src/rendering/layer.dart.js 1515:50 addChildrenToScene
    js_primitives.dart:30 packages/flutter/src/rendering/layer.dart.js 1620:12 addToScene
    js_primitives.dart:30 packages/flutter/src/rendering/layer.dart.js 891:12 [_addToSceneWithRetainedRendering]
    js_primitives.dart:30 packages/flutter/src/rendering/layer.dart.js 1515:50 addChildrenToScene
    js_primitives.dart:30 packages/flutter/src/rendering/layer.dart.js 1620:12 addToScene
    js_primitives.dart:30 packages/flutter/src/rendering/layer.dart.js 891:12 [_addToSceneWithRetainedRendering]
    js_primitives.dart:30 packages/flutter/src/rendering/layer.dart.js 1515:50 addChildrenToScene
    js_primitives.dart:30 packages/flutter/src/rendering/layer.dart.js 1620:12 addToScene
    js_primitives.dart:30 packages/flutter/src/rendering/layer.dart.js 891:12 [_addToSceneWithRetainedRendering]
    js_primitives.dart:30 packages/flutter/src/rendering/layer.dart.js 1515:50 addChildrenToScene
    js_primitives.dart:30 packages/flutter/src/rendering/layer.dart.js 1723:12 addToScene
    js_primitives.dart:30 packages/flutter/src/rendering/layer.dart.js 891:12 [_addToSceneWithRetainedRendering]
    js_primitives.dart:30 packages/flutter/src/rendering/layer.dart.js 1515:50 addChildrenToScene
    js_primitives.dart:30 packages/flutter/src/rendering/layer.dart.js 1620:12 addToScene
    js_primitives.dart:30 packages/flutter/src/rendering/layer.dart.js 891:12 [_addToSceneWithRetainedRendering]
    js_primitives.dart:30 packages/flutter/src/rendering/layer.dart.js 1515:50 addChildrenToScene
    js_primitives.dart:30 packages/flutter/src/rendering/layer.dart.js 2431:12 addToScene
    js_primitives.dart:30 packages/flutter/src/rendering/layer.dart.js 891:12 [_addToSceneWithRetainedRendering]
    js_primitives.dart:30 packages/flutter/src/rendering/layer.dart.js 1515:50 addChildrenToScene
    js_primitives.dart:30 packages/flutter/src/rendering/layer.dart.js 1620:12 addToScene
    js_primitives.dart:30 packages/flutter/src/rendering/layer.dart.js 891:12 [_addToSceneWithRetainedRendering]
    js_primitives.dart:30 packages/flutter/src/rendering/layer.dart.js 1515:50 addChildrenToScene
    js_primitives.dart:30 packages/flutter/src/rendering/layer.dart.js 1620:12 addToScene
    js_primitives.dart:30 packages/flutter/src/rendering/layer.dart.js 891:12 [_addToSceneWithRetainedRendering]
    js_primitives.dart:30 packages/flutter/src/rendering/layer.dart.js 1515:50 addChildrenToScene
    js_primitives.dart:30 packages/flutter/src/rendering/layer.dart.js 2073:12 addToScene
    js_primitives.dart:30 packages/flutter/src/rendering/layer.dart.js 1299:12 buildScene
    js_primitives.dart:30 packages/flutter/src/rendering/layer.dart.js 4918:48 compositeFrame
    js_primitives.dart:30 packages/flutter/src/rendering/layer.dart.js 6164:25 drawFrame
    js_primitives.dart:30 packages/flutter/src/widgets/widget_span.dart.js 51658:15 drawFrame
    js_primitives.dart:30 packages/flutter/src/rendering/layer.dart.js 6124:12 [_handlePersistentFrameCallback]
    js_primitives.dart:30 packages/flutter/src/scheduler/binding.dart.js 776:9 [_invokeFrameCallback]
    js_primitives.dart:30 packages/flutter/src/scheduler/binding.dart.js 744:37 handleDrawFrame
    js_primitives.dart:30 packages/flutter/src/scheduler/binding.dart.js 699:12 [_handleDrawFrame]
    js_primitives.dart:30 lib/_engine/engine/platform_dispatcher.dart 896:13 invoke
    js_primitives.dart:30 lib/_engine/engine/platform_dispatcher.dart 145:5 invokeOnDrawFrame
    js_primitives.dart:30 lib/_engine/engine.dart 259:45
    js_primitives.dart:30 ════════════════════════════════════════════════════════════════════════════════════════════════════
    2js_primitives.dart:30 Another exception was thrown: UnimplementedError
    5805js_primitives.dart:30 Another exception was thrown: PersistedPhysicalShape: is in an unexpected state. ]

@Ahmadre
Copy link

Ahmadre commented May 3, 2021

@diegoveloper , thanks for patience on this issue. We have a fix, tested with your DartPad sample. It should land shortly in master. Great sample btw.

Thank you guys soo much :)) it also works in beta channel

@Ahmadre
Copy link

Ahmadre commented May 5, 2021

Is there any plan to have this on the stable channel?

@renanmgs
Copy link

Any update?
In some mobile resolutions is doesn't seem to work.

Desktop:
image

Pixel 2:
image

Iphone:
image

On my physical device don't work too.

@renanmgs
Copy link

Closing this as it seems from #52967 (comment) and @ferhatb's comment above that ShaderMask is now supported on web. Let me know if that's not right!

Appears to be not working as expected in some mobile browsers.

@justinmc
Copy link
Contributor Author

@renanmgs Can you open a new issue with instructions to reproduce and tag me and @ferhatb?

@renanmgs
Copy link

@justinmc Its very simple, just an image with a LinearGradient from black to transparent. In some mobile browsers the gradient don't work. Its reproducible in chrome in the Device Toolbar. Some Mobile aspects the gradient work as expected, in others (like Pixel 2) don't. In every mobile browser that i tested physically does not work as well.

But i can open in a new issue if you really want.

@justinmc
Copy link
Contributor Author

Yes please if you have time! That way this bug will get triaged and someone will look at it.

sfshaza2 pushed a commit to flutter/website that referenced this issue Jul 14, 2021
As the ShaderMask should work again (flutter/flutter#44152), the notice that it would not work was removed
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
c: new feature Nothing broken; request for a new capability c: rendering UI glitches reported at the engine/skia rendering level customer: crowd Affects or could affect many people, though not necessarily a specific customer. customer: webeap e: web_canvaskit CanvasKit (a.k.a. Skia-on-WebGL) rendering backend for Web e: web_html HTML rendering backend for Web engine flutter/engine repository. See also e: labels. P2 Important issues not at the top of the work list platform-web Web applications specifically
Development

No branches or pull requests