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

Implement Web Codecs for Skwasm #42184

Merged
merged 14 commits into from May 25, 2023
Merged

Conversation

eyebrowsoffire
Copy link
Contributor

@eyebrowsoffire eyebrowsoffire commented May 20, 2023

This implements making images from web browser codecs.

This implements a JS support library as well, which allows both the main thread and the background thread to keep a registry of JS objects that can be referenced by a numeric ID and transferred between each other.

@flutter-dashboard flutter-dashboard bot added the platform-web Code specifically for the web engine label May 20, 2023
@eyebrowsoffire eyebrowsoffire marked this pull request as ready for review May 23, 2023 23:04
@flutter-dashboard
Copy link

Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change).

If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review.

Changes reported for pull request #42184 at sha bb32529

lib/web_ui/lib/src/engine/image_decoder.dart Show resolved Hide resolved
lib/web_ui/lib/src/engine/image_decoder.dart Outdated Show resolved Hide resolved
lib/web_ui/lib/src/engine/image_decoder.dart Outdated Show resolved Hide resolved
final int videoFrameId = surface.acquireObjectId();
skwasmInstance.skwasmRegisterObject(videoFrameId.toJS, frame as JSAny);
skwasmInstance.skwasmTransferObjectToThread(videoFrameId.toJS, surface.threadId.toJS);
return SkwasmImage(imageCreateFromVideoFrame(
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a potential race between the transfer and SkImage initialization?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, there isn't, although I could see why you might think so. It is true that the SkImage is being created synchronously on the UI thread, but it's the image's generator that actually attempts to grab the video frame by its ID and convert it to a texture, and that generator is always run on the web worker right before the image is being either drawn to the actual graphics surface or being rasterized to pixels. Any call that would draw or rasterize the image is sent to the web worker via a postMessage, and the postMessage queue is serial, so those calls are guaranteed to happen after the postMessage that transfers the video frame.

lib/web_ui/skwasm/library_skwasm_support.js Show resolved Hide resolved
lib/web_ui/skwasm/surface.cpp Outdated Show resolved Hide resolved
@flutter-dashboard
Copy link

Golden file changes are available for triage from new commit, Click here to view.

Changes reported for pull request #42184 at sha 2969e11

Copy link
Contributor

@harryterkelsen harryterkelsen left a comment

Choose a reason for hiding this comment

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

LGTM

@eyebrowsoffire eyebrowsoffire added the autosubmit Merge PR when tree becomes green via auto submit App label May 25, 2023
Copy link
Contributor

@yjbanov yjbanov left a comment

Choose a reason for hiding this comment

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

lgtm

@auto-submit auto-submit bot merged commit 99f2653 into flutter:main May 25, 2023
29 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request May 25, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request May 25, 2023
…127619)

flutter/engine@6ff02c1...99f2653

2023-05-25 jacksongardner@google.com Implement Web Codecs for Skwasm (flutter/engine#42184)
2023-05-25 godofredoc@google.com Move linux clang tidy to engine_v2. (flutter/engine#42112)
2023-05-25 skia-flutter-autoroll@skia.org Roll Skia from 69d0aa065992 to e648bf802cd2 (11 revisions) (flutter/engine#42323)
2023-05-25 jacksongardner@google.com Only use 8 cores for web test compilation. (flutter/engine#42321)
2023-05-25 skia-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from nLnQzTesaABpgroOl... to DNwJQMQZladAsKTjv... (flutter/engine#42322)
2023-05-25 valentin.haloiu@gmail.com Dynamically link against system fontconfig (flutter/engine#40725)

Also rolling transitive DEPS:
  fuchsia/sdk/core/linux-amd64 from nLnQzTesaABp to DNwJQMQZladA

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC bdero@google.com,rmistry@google.com,zra@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App platform-web Code specifically for the web engine will affect goldens
Projects
None yet
3 participants