Commit Graph

55 Commits

Author SHA1 Message Date
Michael Goderbauer
6f09064e78
Stand-alone widget tree with multiple render trees to enable multi-view rendering (#125003)
This change enables Flutter to generate multiple Scenes to be rendered into separate FlutterViews from a single widget tree. Each Scene is described by a separate render tree, which are all associated with the single widget tree.

This PR implements the framework-side mechanisms to describe the content to be rendered into multiple views. Separate engine-side changes are necessary to provide these views to the framework and to draw the framework-generated Scene into them.

## Summary of changes

The details of this change are described in [flutter.dev/go/multiple-views](https://flutter.dev/go/multiple-views). Below is a high-level summary organized by layers.

### Rendering layer changes

* The `RendererBinding` no longer owns a single `renderView`. In fact, it doesn't OWN any `RenderView`s at all anymore. Instead, it offers an API (`addRenderView`/`removeRenderView`) to add and remove `RenderView`s that then will be MANAGED by the binding. The `RenderView` itself is now owned by a higher-level abstraction (e.g. the `RawView` Element of the widgets layer, see below), who is also in charge of adding it to the binding. When added, the binding will interact with the `RenderView` to produce a frame (e.g. by calling `compositeFrame` on it) and to perform hit tests for incoming pointer events. Multiple `RenderView`s can be added to the binding (typically one per `FlutterView`) to produce multiple Scenes.
* Instead of owning a single `pipelineOwner`, the `RendererBinding` now owns the root of the `PipelineOwner` tree (exposed as `rootPipelineOwner` on the binding). Each `PipelineOwner` in that tree (except for the root) typically manages its own render tree typically rooted in one of the `RenderView`s mentioned in the previous bullet. During frame production, the binding will instruct each `PipelineOwner` of that tree to flush layout, paint, semantics etc. A higher-level abstraction (e.g. the widgets layer, see below) is in charge of adding `PipelineOwner`s to this tree.
* Backwards compatibility: The old `renderView` and `pipelineOwner` properties of the `RendererBinding` are retained, but marked as deprecated. Care has been taken to keep their original behavior for the deprecation period, i.e. if you just call `runApp`, the render tree bootstrapped by this call is rooted in the deprecated `RendererBinding.renderView` and managed by the deprecated `RendererBinding.pipelineOwner`.

### Widgets layer changes

* The `WidgetsBinding` no longer attaches the widget tree to an existing render tree. Instead, it bootstraps a stand-alone widget tree that is not backed by a render tree. For this, `RenderObjectToWidgetAdapter` has been replaced by `RootWidget`.
* Multiple render trees can be bootstrapped and attached to the widget tree with the help of the `View` widget, which internally is backed by a `RawView` widget. Configured with a `FlutterView` to render into, the `RawView` creates a new `PipelineOwner` and a new `RenderView` for the new render tree. It adds the new `RenderView` to the `RendererBinding` and its `PipelineOwner` to the pipeline owner tree.
* The `View` widget can only appear in certain well-defined locations in the widget tree since it bootstraps a new render tree and does not insert a `RenderObject` into an ancestor. However, almost all Elements expect that their children insert `RenderObject`s, otherwise they will not function properly. To produce a good error message when the `View` widget is used in an illegal location, the `debugMustInsertRenderObjectIntoSlot` method has been added to Element, where a child can ask whether a given slot must insert a RenderObject into its ancestor or not. In practice, the `View` widget can be used as a child of the `RootWidget`, inside the `view` slot of the `ViewAnchor` (see below) and inside a `ViewCollection` (see below). In those locations, the `View` widget may be wrapped in other non-RenderObjectWidgets (e.g. InheritedWidgets).
* The new `ViewAnchor` can be used to create a side-view inside a parent `View`. The `child` of the `ViewAnchor` widget renders into the parent `View` as usual, but the `view` slot can take on another `View` widget, which has access to all inherited widgets above the `ViewAnchor`. Metaphorically speaking, the view is anchored to the location of the `ViewAnchor` in the widget tree.
* The new `ViewCollection` widget allows for multiple sibling views as it takes a list of `View`s as children. It can be used in all the places that accept a `View` widget.

## Google3

As of July 5, 2023 this change passed a TAP global presubmit (TGP) in google3: tap/OCL:544707016:BASE:545809771:1688597935864:e43dd651

## Note to reviewers

This change is big (sorry). I suggest focusing the initial review on the changes inside of `packages/flutter` first. The majority of the changes describe above are implemented in (listed in suggested review order):

* `rendering/binding.dart`
* `widgets/binding.dart`
* `widgets/view.dart`
* `widgets/framework.dart`

All other changes included in the PR are basically the fallout of what's implemented in those files. Also note that a lot of the lines added in this PR are documentation and tests.

I am also very happy to walk reviewers through the code in person or via video call, if that is helpful.

I appreciate any feedback.

## Feedback to address before submitting ("TODO")
2023-07-17 16:14:08 +00:00
Tomasz Gucio
99c7e9f088
Add spaces after flow control statements (#126320) 2023-05-15 11:07:30 +02:00
Michael Goderbauer
a599c08c32
Remvoe last few references to window singleton (#122644)
Remove last few references to window singleton
2023-03-15 00:34:34 +00:00
Michael Goderbauer
b4019f9884
Reland "Remove single view assumption from TestViewConfiguration (#122352)" (#122414)
Reland "Remove single view assumption from TestViewConfiguration (#122352)"
2023-03-10 19:30:34 +00:00
Casey Hillers
1f42612323
Revert PRs relating to single window assumption (#122369)
* Revert "Remove references to BindingBase.window (#122119)"

This reverts commit c7681f00cf.

* Revert "Remove another reference to BindingBase.window (#122341)"

This reverts commit 6ec4445063.

* Revert "Reland (2): Removes single window assumptions from `flutter_test` (#122233)"

This reverts commit eb3d317ea0.

* Revert "Remove single view assumption from TestViewConfiguration (#122352)"

This reverts commit 927289fb4e.

* Revert "Updates `flutter/test/cupertino` to no longer use `TestWindow` (#122325)"

This reverts commit 67e17e45f0.

* Revert "Updates `flutter/test/gestures` to no longer reference `TestWindow` (#122327)"

This reverts commit c2a5111cc0.

* Revert "Updates `flutter/test/rendering` to no longer use `TestWindow` (#122347)"

This reverts commit 28b65e089b.

* Revert "Updates `flutter_localizations/test` to stop using `TestWindow` (#122321)"

This reverts commit 01367d52d7.
2023-03-09 22:53:38 -08:00
Michael Goderbauer
927289fb4e
Remove single view assumption from TestViewConfiguration (#122352)
Remove single view assumption from TestViewConfiguration
2023-03-10 01:54:00 +00:00
Lioness100
26b6c1bedd
Fix typos (#121171)
* Fix typos

* lowercase animated & opacity

* Undo typo fix

---------

Co-authored-by: Michael Goderbauer <goderbauer@google.com>
2023-02-23 19:43:21 +00:00
Michael Goderbauer
f291eb3495
Remove unnecessary null checks in integration_test (#118861) 2023-01-20 18:30:08 +00:00
Kenzie Davisson
725c1415df
Fix screenshot testing for flutter web integration_test (#117114)
* Fix screenshot testing for flutter web integration_test

* update packages

* fix method signature and todo

* Run tests on CI

* fix type

* remove silences

* Add docs

* fix comment

* fix whitespace

* review comments
2022-12-22 21:34:04 +00:00
Alexandre Ardhuin
ccd33631e3
enable combinators_ordering (#107847) 2022-07-18 22:04:07 +00:00
Pierre-Louis
74cfc3db67
Use curly_braces_in_flow_control_structures for non-flutter packages (#104629)
* Use `curly_braces_in_flow_control_structures` for `packages/flutter_driver`

* Use `curly_braces_in_flow_control_structures` for `packages/flutter_goldens`

* Use `curly_braces_in_flow_control_structures` for `packages/flutter_goldens_client`

* Use `curly_braces_in_flow_control_structures` for `packages/flutter_localizations`

* Use `curly_braces_in_flow_control_structures` for `packages/flutter_test`

* Use `curly_braces_in_flow_control_structures` for `packages/flutter_web_plugins`

* fix comments

* Use `curly_braces_in_flow_control_structures` for `packages/integration_test`

* fix indentation
2022-05-25 20:01:11 +02:00
Alexandre Ardhuin
07f1c20474
add missing trailing commas in list/set/map literals (#102585) 2022-04-27 09:15:35 +02:00
Ian Hickson
ab89ce285f
Clean up the bindings APIs. (#89451) 2022-02-03 14:55:15 -08:00
Dan Field
ffba5c425c
Print a more helpful error if DDS is enabled when running integration_test and enableTimeline is called (#92509) 2022-01-19 17:50:18 -08:00
Ian Hickson
f25b833f27
Enable avoid_print lint. (#91444) 2021-10-07 16:48:04 -07:00
Mouad Debbar
c2ea78d231
Revert "Enable avoid_print lint. (#91332)" (#91438)
This reverts commit cb378edc9e.
2021-10-07 16:16:17 -04:00
Ian Hickson
cb378edc9e
Enable avoid_print lint. (#91332) 2021-10-07 09:53:03 -07:00
Ian Hickson
2420718389
Remove our extra timeout logic. (#89952) 2021-09-15 09:42:05 -07:00
Phil Quitslund
975fcc1f2f
master->main deafult branch migration (#89782) 2021-09-10 15:42:03 -07:00
Dan Field
1745402d76
Document multi-timeline usage (#88604) 2021-09-08 17:12:04 -07:00
Dan Field
c5861cfb56
Revert "Fix DPR in test view configuration (#88609)" (#88889)
This reverts commit 5feee0d8fa.
2021-08-25 10:09:03 -07:00
Dan Field
5feee0d8fa
Fix DPR in test view configuration (#88609) 2021-08-24 14:26:54 -07:00
Dan Field
d5d8265079
Revert "Write timelines to separate files (#88473)" (#88594)
This reverts commit fa83fefa42.
2021-08-20 11:57:32 -07:00
Dan Field
fa83fefa42
Write timelines to separate files (#88473) 2021-08-20 09:47:04 -07:00
Emmanuel Garcia
0504fac7e2
Android e2e screenshot (#84472) 2021-07-20 13:36:04 -07:00
Ren You
3dea9f0251
Revert "Clean up the bindings APIs (#86438)" (#86484)
This reverts commit d056500bfe.
2021-07-15 09:29:16 -07:00
Ian Hickson
d056500bfe
Clean up the bindings APIs (#86438) 2021-07-14 14:41:24 -07:00
Zachary Anderson
7f741e9181
Revert "Clean up the bindings APIs (#86388)" (#86404)
This reverts commit 31de052e3f.
2021-07-13 21:32:29 -07:00
Ian Hickson
31de052e3f
Clean up the bindings APIs (#86388) 2021-07-13 18:31:11 -07:00
Ian Hickson
c800b9c3e4
Revert "Clean up the bindings APIs (#83843)" (#86386)
This reverts commit e2490f2906.
2021-07-13 15:47:40 -07:00
Ian Hickson
e2490f2906
Clean up the bindings APIs (#83843) 2021-07-13 12:41:03 -07:00
Jia Hao
446673a65f
[integration_test] Fix early reporting of results (#83685) 2021-06-01 13:24:04 -07:00
Dan Field
304b9c668e
Reland GC tracking benchmarks (#82069) 2021-05-14 19:59:24 -07:00
Jia Hao
099f1162ac
[integration_test] Don't log exceptions twice (#81812) 2021-05-07 17:49:02 -07:00
Dan Field
3101374f60
Revert "Reland GC benchmark changes again (#82042)" (#82059)
This reverts commit 99a947c3e5.
2021-05-07 13:19:56 -07:00
Dan Field
99a947c3e5
Reland GC benchmark changes again (#82042) 2021-05-07 12:29:01 -07:00
Zachary Anderson
4056ac057d
Revert "Reland GC related bench update (#81794)" (#82005)
This reverts commit 714dea5e03.
2021-05-06 19:03:59 -07:00
Dan Field
714dea5e03
Reland GC related bench update (#81794) 2021-05-06 16:49:04 -07:00
Phil Quitslund
61c30c41b2
fix sort_directives violations (#80817) 2021-04-21 13:49:03 -07:00
Jia Hao
e868a8335b
Remove the warning about the Integration Test plugin (#79520) 2021-04-01 18:49:02 -07:00
Michael Goderbauer
a7e3b1a35d
Clean up ignores that are not ignoring anything (#78493) 2021-03-19 15:32:46 -07:00
Jonah Williams
e52ebb3ad9
[integration_test] delay for at least one frame timing. (#78055) 2021-03-12 16:53:02 -08:00
Michael Goderbauer
cb867bbedc
Enable unnecessary_await_in_return lint (#77434) 2021-03-05 18:38:15 -08:00
Michael Goderbauer
7b251f5f37
Enable use_function_type_syntax_for_parameters lint (#77163) 2021-03-04 08:59:17 -08:00
Dan Field
d3092541e2
Reland integration_test NNBD (#75074)
* Revert "Revert "NNBD integration_test (#74922)" (#75030)"

This reverts commit 87b043658b.

* fix bad merge issues
2021-02-01 10:19:14 -08:00
Ian Hickson
87b043658b
Revert "NNBD integration_test (#74922)" (#75030)
This reverts commit cca9592f0e.
2021-01-29 15:46:21 -08:00
Dan Field
cca9592f0e
NNBD integration_test (#74922) 2021-01-29 14:31:06 -08:00
Dan Field
3de9342ffa
No test core (#74065)
* Revert "[integration_test] Fix incorrect logging for the legacy reporter (#72699)"

This reverts commit 57e134058f.

* Revert reporter
2021-01-15 20:05:10 -08:00
Jia Hao
57e134058f
[integration_test] Fix incorrect logging for the legacy reporter (#72699) 2020-12-21 10:29:02 -08:00
Jia Hao
c2bfb7b348
[integration_test] Wrap pumped widgets with a RepaintBoundary (#70368) 2020-12-09 16:33:04 -08:00