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

A Unified Frontend Server for Flutter #39126

Open
chinmaygarde opened this issue Oct 25, 2019 · 3 comments
Open

A Unified Frontend Server for Flutter #39126

chinmaygarde opened this issue Oct 25, 2019 · 3 comments
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues.

Comments

@chinmaygarde
Copy link
Member

Background

Currently, Flutter on non-Fuchsia platforms uses the Flutter Frontend Server to generate the Dart kernel binaries (.dill files) consumed by the Flutter engine on the target. This Frontend server is made available to Flutter SDK consumers via a snapshot of the Dart package (available as a prebuilt downloaded as part of the Flutter SDK to artifacts/engine/darwin-x64/frontend_server.dart.snapshot). The Flutter Frontend Server is thin wrapper around the Dart Frontend. This component lives in the Flutter Engine source tree today.

For Fuchsia targets, a very similar tool called the Kernel Compiler is used to generate multiple Dart Kernel Binary parts (.dillp files). These files are consumed by the Flutter engine on the target in much the same way the .dill files are consumed on non-Fuchsia platforms. The advantage of using .dillp files is the ability to leverage the deduplication of common .dillp files on Fuchsia. The Kernel Compiler also generates a manifest that lists all the parts generated so the the Flutter runner can fetch them at runtime. Just like the Flutter Frontend Server, the Kernel Compiler is also a very thin wrapper around the Dart Frontend. This component lives in the Fuchsia Topaz source tree today. But as part of the FL-250 transition, a copy of the same also lives in the Flutter Engine source tree. While a snapshot of the same is generated as part of engine builds, it is currently unused in favor of just using the component directly from the Fuchsia source tree.

Proposal

Both the Kernel Compiler and the Flutter Frontend Server are extremely thin wrappers around the Dart Frontend. It would be desirable for that component to be augmented to handle both the Flutter (.dill) & Fuchsia (.dillp) use cases. This unifed frontend server can then be rolled (as a snapshot) as part of the Dart SDK. This would simplify rolls by reducing points of potential failures.

A initial concern was that Flutter specific smarts (tracking widget construction, etc.) would now need to live in the Dart SDK repository. After consulting members of the Dart team, it is found that this is already the case today as some information was being lost when all Flutter specific logic lived in the just the Flutter Frontend Server in the Flutter Engine repository.

The Ideal

Instead of having three components that are essentially identical (Flutter Frontend Server, Kernel Compiler & the Dart internal Frontend Server used for internal testing) and thin wrappers around the Dart Frontend, the Dart SDK vends a single tool that targets all listed use cases. This tool is rolled as part of the Dart SDK. The Flutter Frontend Server & Kernel Compiler are removed from the Flutter & Fuchsia source trees respectively. Flutter rolles are now simplified as the tool is already part of the Dart roll. This would require only minor modifications to the tool invocations.

@chinmaygarde
Copy link
Member Author

cc @iskakaushik who ran into this issue as part of FL-250 prerequisites. cc @aam, @rmacnak-google for details/corrections on the proposal.

@devoncarew
Copy link
Member

cc @mraleph @a-siva

@devoncarew devoncarew added the area-front-end Use area-front-end for front end / CFE / kernel format related issues. label Oct 28, 2019
@mraleph
Copy link
Member

mraleph commented Oct 28, 2019

/cc @alexmarkov @mkustermann

dart-bot pushed a commit that referenced this issue Oct 30, 2019
…ifest generation.

Bug: #39126
Change-Id: I79a44316bea4350433a320794569c70ed3baa649
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123464
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
dart-bot pushed a commit that referenced this issue May 20, 2021
This change adds toString transformation to gen_kernel and
frontend_server tools in Dart SDK.

The implementation and tests are derived from
pkg/frontend_server/lib/src/to_string_transformer.dart and
https://github.com/flutter/engine/tree/master/flutter_frontend_server/test.

In addition to _KeepToString in dart:ui, toString transformation
now supports @pragma('flutter:keep-to-string') to exclude
certain toString methods from the transformation without depending
on dart:ui.

pkg/frontend_server/lib/src/to_string_transformer.dart is not
cleaned up in this change yet as it is still used by Flutter
engine. Cleanup will be done after Flutter engine is cleaned up,
after it is switched to the implementation of toString transformer
added in this change.

This is also a step towards a unified kernel compiler
(#39126).

TEST=pkg/vm/test/transformations/to_string_transformer_test.dart

Issue: #46022
Issue: #39126

Change-Id: Icbfd3fa193d54f1fc6b2d7fa0bace82b3704f91f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/200525
Reviewed-by: Dan Field <dnfield@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues.
Projects
None yet
Development

No branches or pull requests

3 participants