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] Multi-view Embedding Support #118481

Closed
ditman opened this issue Jan 13, 2023 · 11 comments
Closed

[web] Multi-view Embedding Support #118481

ditman opened this issue Jan 13, 2023 · 11 comments
Assignees
Labels
a: existing-apps Integration with existing apps via the add-to-app flow engine flutter/engine repository. See also e: labels. P1 High-priority issues at the top of the work list platform-web Web applications specifically team-web Owned by Web platform team triaged-web Triaged by Web platform team

Comments

@ditman
Copy link
Member

ditman commented Jan 13, 2023

Get the code ready to support the multi-view embedding feature. Some changes:

  • Accept a hostElements array in the Engine configuration
  • Refactor the current View Embedder so it's not a singleton anymore.
    • Each View should know how to embed itself, or have an Embedding Strategy associated with it. See this doc.

There's multiple assumptions made in the current view embedder that only one view is going to exist at a time (like the addSceneToSceneHost method, which need to be delegated to each view implementation).

For simplicity, the new design should be something similar to:

  • The platform_dispatcher continues being a singleton that coordinates the engine (in the future, this should be an actual object that gets instantiated).
    • The platform_dispatcher contains a Map<ViewId, View> where all the views are cached for access later.
    • The platform_dispatcher can initialize new Views depending on their configuration (create the appropriate DOM structure for the view, create the view itself), and cache it in the view cache.
    • The platform_dispatcher should receive a view Id for every view "operation".
      • Operations should fetch a view by its id, and operate on it, rather than delegate it to the view_embedder. Look how the current implementation of render ignores the passed-in view.

Most of the above should be implementable in the current state of the engine, without having to wait for the full-blown multi-view setup (at least, to make it work in single-view with the refactored multi-view architecture).

@ditman ditman self-assigned this Jan 13, 2023
@darshankawar darshankawar added in triage Presently being triaged by the triage team engine flutter/engine repository. See also e: labels. platform-web Web applications specifically and removed in triage Presently being triaged by the triage team labels Jan 16, 2023
@Hixie Hixie added the a: existing-apps Integration with existing apps via the add-to-app flow label Jan 19, 2023
@yjbanov yjbanov added the P1 High-priority issues at the top of the work list label Jan 23, 2023
@ditman
Copy link
Member Author

ditman commented Mar 25, 2023

Related: #122850

@yjbanov
Copy link
Contributor

yjbanov commented Apr 27, 2023

First milestone could be: we have an engine test that creates two FlutterView instances and renders a Scene into each. This way we don't have a dependency on the framework's multi-view support while making progress on the web engine side.

@flutter-triage-bot flutter-triage-bot bot added multiteam-retriage-candidate team-web Owned by Web platform team triaged-web Triaged by Web platform team labels Jul 8, 2023
@NashIlli
Copy link

Any updates about this?

@ditman
Copy link
Member Author

ditman commented Jan 3, 2024

@NashIlli it's WIP.

@leoxagy12
Copy link

This would be extremely useful. I was thinking of using flutter for improving pieces of a legacy web app but the limitation of one single embedded component forbids continuing with this idea for the moment. Hope this gets completed soon as it will open many doors for flutter.

@ditman
Copy link
Member Author

ditman commented Jan 26, 2024

@leoxagy12 it's WIP, but lots of work to do. Here's an old-ish demo.

@sjthn
Copy link

sjthn commented Feb 19, 2024

Hi @ditman , will this enable us to show the required flutter widget(s) on the screen without the need to wrap it with a runApp?

Asking this as I have a usecase to show a flutter widget in a 3rd party webpage that can use any web framework. So we were thinking if a widget alone can be exposed from that flutter module that is already used by the flutter app.

@ditman
Copy link
Member Author

ditman commented Feb 21, 2024

So we were thinking if a widget alone can be exposed from that flutter module that is already used by the flutter app.

@sjthn No, you won't be able to export a widget from a Flutter Web app.

You'll be able to have a flutter web app running, possibly rendering nothing, that knows how to fill in certain "divs" with whatever widget you want. This is controlled from your Flutter app.

You can render as many divs as you want from Flutter with a single runApp (my demo app above only has one runApp, but it can render to as many divs as needed)

@p-mazhnik
Copy link
Contributor

@yjbanov
Copy link
Contributor

yjbanov commented Feb 26, 2024

This is done.

@yjbanov yjbanov closed this as completed Feb 26, 2024
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 Mar 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: existing-apps Integration with existing apps via the add-to-app flow engine flutter/engine repository. See also e: labels. P1 High-priority issues at the top of the work list platform-web Web applications specifically team-web Owned by Web platform team triaged-web Triaged by Web platform team
Projects
None yet
Development

No branches or pull requests

8 participants