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

[web] Render PlatformViews with SLOT tags. #25747

Merged
merged 37 commits into from
May 21, 2021
Merged

[web] Render PlatformViews with SLOT tags. #25747

merged 37 commits into from
May 21, 2021

Conversation

ditman
Copy link
Member

@ditman ditman commented Apr 24, 2021

Render PlatformViews in SLOT tags. To do so:

  • Wraps most of the DOM from a flutter app in the Shadow DOM of flt-glass-pane (was [web] Wrap all the contents of the glass-pane in a shadow root. #25483)
  • Unifies the Platform View lifecycle in a PlatformViewManager class. That class keeps track of platform view factory functions, their rendered output, and the SLOTs for the Shadow DOM.
    • Previously a PlatformView was a single DOM node, but now it has been split in two:
      • The slot(which flutter is able to move around within the render tree).
      • The content (which is always a direct child of the flt-glass-pane element, and contains the rendered output of a platform view factory).
  • Platform messages related to platform views are now handled by a PlatformViewMessageHandler class, which is configured in the engine's platform_dispatcher.dart. Platform Messages for Platform Views are now more easily testable.
  • Unused code across the engine has been removed (everything related to the old way of handling platform views in canvaskit and html renderers).

Fixes

Testing

  • Deployed the Gallery App using this version of the engine: https://dit-gallery.web.app
  • All existing tests pass.
  • Added new tests for the new classes added.

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.
  • The reviewer has submitted any presubmit flakes in this PR using the engine presubmit flakes form before re-triggering the failure.

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

@flutter-dashboard flutter-dashboard bot added the platform-web Code specifically for the web engine label Apr 24, 2021
@google-cla google-cla bot added the cla: yes label Apr 24, 2021
@ditman ditman changed the title [WIP] [web] Render PlatformViews with SLOT tags. [web] Render PlatformViews with SLOT tags. May 12, 2021
@ditman ditman marked this pull request as ready for review May 12, 2021 21:30
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.

Mostly LGTM with some nits and test fixes

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

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.

mostly LGTM

_releaseOverlay(unusedViewId);
_rootViews[unusedViewId]?.remove();
}
disposeViews(unusedViews);
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure this new code will actually dispose of "disposed" views. In the old code we kept a list of views which were disposed, and then later we disposed them. In this code we are only disposing views which are trying to be composited into the scene but were never registered. In the old code we would delete disposed views whether or not they are being actively composited this frame.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah yes, the thing is that in the old code this was coupled with the creation/destruction of the actual content of the platform view in the DOM.

Now, slots are "lightweight" so they can be destroyed/recreated per frame without impacting performance, and the actual platform view (with the heavy iframe) will still get destroyed when the framework signals a disposal.

Can you think of some example where this code might be leaking unused views?

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

@ditman

This comment has been minimized.

@ditman

This comment has been minimized.

ditman added 20 commits May 20, 2021 12:09
…ws in a frame can be reported later by submitFrame.
… non-functioning platform view when under testing)
Remove caching ability from Slots (only required for the canvaskit rendering, will be added there)
…nd the clipCount of views in the canvaskit backend.
@ditman ditman added the waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land. label May 21, 2021
@fluttergithubbot fluttergithubbot merged commit b5f8141 into flutter:master May 21, 2021
@ditman ditman deleted the platform-views-in-slots-no-flag branch May 21, 2021 00:33
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request May 21, 2021
stuartmorgan added a commit to flutter/plugins that referenced this pull request May 21, 2021
Replace the per-platform-view shadow dom query with a top-level shadow dom query.

Fixes breakage from flutter/engine#25747
fotiDim pushed a commit to fotiDim/plugins that referenced this pull request Sep 13, 2021
Replace the per-platform-view shadow dom query with a top-level shadow dom query.

Fixes breakage from flutter/engine#25747
henkibro pushed a commit to henkibro/url_launcher that referenced this pull request Mar 1, 2022
Replace the per-platform-view shadow dom query with a top-level shadow dom query.

Fixes breakage from flutter/engine#25747
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes platform-web Code specifically for the web engine waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants