125 Commits

Author SHA1 Message Date
Matan Lurey
edb665c82d Make {shell|lib/ui}/... compatible with .clang_tidy. (flutter/engine#48242)
This is mostly just rename `ThreadHost::Type::{IDENTIFIER}` to
`kIdentifier`.

I also ignored some enum violations that are in public APIs.
2023-11-21 12:29:14 -08:00
Tong Mu
87171e7339 Reland 2: Multiview Pipeline (flutter/engine#47239)
The last attempt https://github.com/flutter/engine/pull/47234 was reverted because there was another test merged in the meantime that violates the rule added in this PR.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-10-23 23:46:25 +00:00
Zachary Anderson
d549483298 Revert "Reland: Multiview pipeline " (flutter/engine#47237)
Reverts flutter/engine#47234

Failures like
https://ci.chromium.org/ui/p/flutter/builders/prod/Mac%20Production%20Engine%20Drone/186568/overview
making the tree red.
2023-10-23 15:17:36 -07:00
Tong Mu
9ed503a734 Reland: Multiview pipeline (flutter/engine#47234)
This PR relands https://github.com/flutter/engine/pull/44473.

The previous PR was immediately reverted after merging because we found that the PR could cause illegal renders to be skipped on debug builds but crash the app on release builds. This PR makes the `Animator::Render` skip illegal renders as well. This should not be the final shape of this feature, and thus a TODO is added.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-10-23 21:35:04 +00:00
auto-submit[bot]
47c3403c39 Reverts "Multiview pipeline" (flutter/engine#47174)
Reverts flutter/engine#44473
Initiated by: dkwingsmt
This change reverts the following previous change:
Original Description:
This PR makes `Animator` able to handle multiple views, and updates unit tests accordingly.

Before:
<img width="543" alt="image" src="https://github.com/flutter/engine/assets/1596656/f7d0e0e4-cc85-4a6e-b516-1896ac3c1b35">

After:
<img width="614" alt="image" src="https://github.com/flutter/engine/assets/1596656/68106301-66ef-4cd1-aeaf-d9c6127ccec2">

Now `Animator::Render` must be called during `Animator::BeginFrame`, which is split into `BeginFrame` and `EndFrame`. This requirement is made possible by https://github.com/flutter/engine/pull/45555. The reason to split is to allow `ShellTest::PumpOneFrame` to insert a render from C++ code.

`ShellTest::PumpOneFrame` is also refactored to allow pumping a frame without any views.

A few unit tests are tweaked to resolve racing condition.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-10-20 20:57:08 +00:00
Tong Mu
1cfde62821 Multiview pipeline (flutter/engine#44473)
This PR makes `Animator` able to handle multiple views, and updates unit tests accordingly.

Before:
<img width="543" alt="image" src="https://github.com/flutter/engine/assets/1596656/f7d0e0e4-cc85-4a6e-b516-1896ac3c1b35">

After:
<img width="614" alt="image" src="https://github.com/flutter/engine/assets/1596656/68106301-66ef-4cd1-aeaf-d9c6127ccec2">

Now `Animator::Render` must be called during `Animator::BeginFrame`, which is split into `BeginFrame` and `EndFrame`. This requirement is made possible by https://github.com/flutter/engine/pull/45555. The reason to split is to allow `ShellTest::PumpOneFrame` to insert a render from C++ code.

`ShellTest::PumpOneFrame` is also refactored to allow pumping a frame without any views.

A few unit tests are tweaked to resolve racing condition.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-10-20 20:38:23 +00:00
gaaclarke
c8aa0844f2 [Impeller] implements a retry mechanism for dart:ui/Image.toByteData. (flutter/engine#46840)
Design doc: [link](https://docs.google.com/document/d/1Uuiw3pdQxNFTA8OQuZ-kuvYg1NB42XgccQCZeqr4oII/edit#heading=h.hn6wreyrz6fm)
fixes: https://github.com/flutter/flutter/issues/135245

One slight deviation from the design doc is that I decided to make ContextMTL respond to changes to the SyncSwitch instead of having it observe the app state directly.  The benefits are:
1) This keeps that functionality in one location
1) It makes writing tests much easier
1) There's no need of conditional compilation between macos and ios
1) There is no need to add an objc class

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-10-16 18:31:13 +00:00
gaaclarke
c053bc814b [Impeller] Started throwing errors if dart:ui/Image.toByteData fails (flutter/engine#46738)
issue: https://github.com/flutter/flutter/issues/135245

This is a first step.  Next we'll implement a retry.

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide] and the [C++,
Objective-C, Java style guides].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I added new tests to check the change I am making or feature I am
adding, or the PR is [test-exempt]. See [testing the engine] for
instructions on writing and running engine tests.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I signed the [CLA].
- [x] All existing and new tests are passing.

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

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[test-exempt]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[C++, Objective-C, Java style guides]:
https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
[testing the engine]:
https://github.com/flutter/flutter/wiki/Testing-the-engine
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
2023-10-13 09:04:47 -07:00
Tong Mu
489f9c3d01 Make updating window metrics multi-view (flutter/engine#43366)
This PR adds multi-view support to various methods that updates the window metrics by adding a `view_id` parameter.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-07-08 05:54:16 +00:00
Dan Field
b6fa0a20a5 Print a warning when a message channel is used on the wrong thread. (flutter/engine#42928)
Fixes https://github.com/flutter/flutter/issues/128746

Prints a warning the first time a platform channel sends a message from the wrong thread with instructions/link to the site about how to fix this.
2023-06-22 18:16:40 +00:00
Tong Mu
57758b70c8 Use ShellTest::Config struct to create Shell (flutter/engine#42332) 2023-06-11 10:38:17 -07:00
Jonah Williams
be33a58e18 [Impeller] Encode render passes concurrently on iOS. (flutter/engine#42028)
Allows pushing encoding of command buffers to a worker thread, relying on the fact that these buffers are always scheduled in the order that they are enqueued. This follows the guidelines from https://developer.apple.com/documentation/metal/mtlcommandbuffer?language=objc
2023-05-23 19:40:05 +00:00
Dan Field
ea5131772d Add a Display API to dart:ui that reports the physical size, DPR, and refresh rate of the main display (flutter/engine#41685)
Fixes https://github.com/flutter/flutter/issues/123307 - for Android, iOS, and Web, for the main display only (https://github.com/flutter/flutter/issues/125938 tracks supporting multiple displays, https://github.com/flutter/flutter/issues/125939 for desktop).

Desktop will need to be implemented for this, but given priority for a couple of our customers targetting foldable devices on Android I'm inclined to get this in before desktop can be finished.

The main concern for this right now is that on some Android foldable devices, setting a preferred orientation will cause letterboxing and the `MediaQuery` will _never_ get the full screen size when unfolded. This causes apps to think the screen is smaller than it is, as they've mainly been using `MediaQueryData.size` to figure this out. Android's recommendation is to not set a preferred orientation, and if you must to use the new method introduced in `ViewUtil.java` to calculate the maximal window size.
2023-05-06 18:28:22 +00:00
Tong Mu
05036058d7 Remove single window assumption from SceneBuilder (flutter/engine#41559)
This PR fixes https://github.com/flutter/flutter/issues/112202. `Scene`
is no longer tied to views, but receives method arguments for view
properties, clearing the path to multiview Flutter.

`Scene` no longer creates a `LayerTree` on construction, but only part
of the config. When a output method is called (`toImage`, `toImageSync`,
or `takeLayerTree`), the `LayerTree` is constructed on the spot. In this
way, all `LayerTree`s return to being `unique_ptr`s instead of
`shared_ptr`s, reverting part of
https://github.com/flutter/engine/pull/35608 . And `Scene` no longer
needs to disfunction after one `takeLayerTree`, since the layer tree
config is never really taken away.

A `device_pixel_ratio` is now added to the parameter list of `Engine::Render` and `Animator::Render`.

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide] and the [C++,
Objective-C, Java style guides].
- [x] 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.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I signed the [CLA].
- [x] All existing and new tests are passing.

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

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[C++, Objective-C, Java style guides]:
https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
[testing the engine]:
https://github.com/flutter/flutter/wiki/Testing-the-engine
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
2023-05-05 11:25:55 -07:00
Dan Field
020577edbb Make NotifyIdle reject close and past deadlines. (flutter/engine#37737)
This patch also eliminates some extraneous tracing that is happening
every frame. It is possible to get the same trace calls by enabling
the API stream if needed.

Also refactors the NotifyIdle callsites to just always work in
TimeDeltas rather than converting back and forth between them and
TimePoints, which I think reads more clearly.
2022-11-18 18:17:53 +00:00
gaaclarke
e41c775200 Removed instances of unnecessary values (flutter/engine#36221) 2022-09-26 21:28:04 +00:00
Jonah Williams
27b4f29d7e Include TextureLayer in contents of toImageSync (flutter/engine#35608) 2022-08-23 02:16:06 +00:00
Casey Hillers
1c20221e24 Revert "Include TextureViews in the output of Scene.toImage[Sync]" (flutter/engine#35587) 2022-08-22 10:26:09 +00:00
Jonah Williams
ed952f4503 Include TextureViews in the output of Scene.toImage[Sync] (flutter/engine#35527)
Update Picture rasterization for toImage to accept a layer tree, optionally flattening on the raster thread if present.
Update Deferred GPU image for toImageSync to accept a layer tree, flattening it the first time it creates an image, storing the resulting display list.

This is also a performance fix for the zoom page transition, which currently does too much work on the UI thread on frame 1
2022-08-19 16:28:30 -07:00
Kaushik Iska
d8e73006e0 Add service protocol method to facilitate getting snapshots (flutter/engine#32628) 2022-04-13 13:39:05 -07:00
ColdPaleLight
58e15e00e3 Don't pause Animator when lifecycle state paused (flutter/engine#30969) 2022-01-27 15:55:07 -08:00
ColdPaleLight
b64598bef6 Refactor type of deadline in the method NotifyIdle to fml::TimePoint (flutter/engine#30737) 2022-01-19 17:25:09 -08:00
Dan Field
87dcc5293f Optmize path volatility tracker (flutter/engine#30299) 2021-12-13 16:59:04 -08:00
Andrei Diaconu
5003f1a91f Reland: Display Features support (flutter/engine#29585) 2021-11-19 18:04:31 -08:00
Zachary Anderson
9dffe2d4f6 Revert "Reland Display Features support (Foldable and Cutout) (#29447)" (flutter/engine#29574)
This reverts commit 28a1c9b21b205a436fad64c9d0bced6b22b4b6a3.
2021-11-06 20:43:44 -07:00
Andrei Diaconu
28a1c9b21b Reland Display Features support (Foldable and Cutout) (flutter/engine#29447) 2021-11-04 13:45:46 -07:00
gaaclarke
8c4ccf58e2 Reapply: Android background platform channels (flutter/engine#29346)
* Revert "Revert "Android Background Platform Channels (#29147)""

This reverts commit 7ed91e14ccc1f5ffc4cb13d1d37e27d370c8f7cd.

* Made this PR less of a breaking change by keeping setMessageHandler's signature the same
2021-10-27 10:11:36 -07:00
Dan Field
d5c36f87f5 Revert "Android Background Platform Channels (#29147)" (flutter/engine#29344)
This reverts commit c40f7670e7aff3a42be2cbac0df067009278d639.
2021-10-26 14:52:13 -07:00
gaaclarke
c40f7670e7 Android Background Platform Channels (flutter/engine#29147) 2021-10-21 16:08:02 -07:00
Dan Field
542896d8c9 Start animator paused (flutter/engine#29007) 2021-10-04 15:48:01 -07:00
Zachary Anderson
86de3b6591 Revert "Display Features support (Foldable and Cutout) (#24756)" (flutter/engine#28447)
This reverts commit 53b9a690c5eb8410c561be43964f350f58347366.
2021-09-03 09:01:15 -07:00
Andrei Diaconu
53b9a690c5 Display Features support (Foldable and Cutout) (flutter/engine#24756)
* Add DisplayFeatures and DisplayCutout to viewport metrics

* WindowManager alpha03 and better documentation

* Fixed formatting

* Fixed failing tests

* Replaced API version code P with 28

* Unnecessary import

* Fixed display features parameters missing

* Documentation changes

* First paragraph is a sentence

* Update androidx window library to version 1.0.0-alpha05

* Improve documentation, remove deprecated display feature call

* Write tests and improve documentation

* Migrate to Window Manager alpha08

* Update androidx window to beta01

* Remove unused import

* Remove window_hook_integration_test.dart

* Fix tests

* Update android_embedding_dependencies version to include androidx.window

* Add androidx.window to test_runner build

* Add empty display features arrays to fuchsia platform view

* Fix tests using final class mocking

* Add missing license header

* Update licenses_golden
2021-09-03 04:02:17 -07:00
Jonah Williams
2cc2854964 Add GestureSettings and configure touch slop from Android ViewConfiguration (flutter/engine#27836) 2021-08-03 12:55:02 -07:00
Kaushik Iska
2fead370b3 Streamline frame timings recording (flutter/engine#25892) 2021-05-07 12:14:01 -07:00
gaaclarke
1734ce7f8a Moved PlatformMessage's to unique_ptrs (flutter/engine#25860) 2021-05-06 20:19:01 -07:00
Kaushik Iska
30e0472687 Pause dart microtasks while UI thread is processing frame workloads (flutter/engine#25789) 2021-04-28 12:39:42 -07:00
Kaushik Iska
17e7c26da8 Revert TaskRunner changes to fix Fuchsia Test failures (flutter/engine#25690) 2021-04-21 09:15:24 -07:00
Kaushik Iska
0aaf693339 Start microtasks only in non-test envs (flutter/engine#25653) 2021-04-20 13:19:07 -07:00
Chinmay Garde
a0a8fb04d8 Wire up Metal shader precompilation from offline training runs. (flutter/engine#25644) 2021-04-19 16:24:02 -07:00
Kaushik Iska
ca7c19d772 Revert "Reland "Remove pipeline in favor of layer tree holder" (#24947)" (flutter/engine#25027) 2021-03-16 16:43:01 -07:00
Kaushik Iska
660e70b250 Reland "Remove pipeline in favor of layer tree holder" (flutter/engine#24947) 2021-03-11 10:56:08 -08:00
gaaclarke
8d44387269 Started initializing the gpu disable syncswitch based on the app state. (flutter/engine#24503) 2021-02-24 22:24:29 -08:00
Kaushik Iska
628624c014 Revert "Reland "Remove pipeline in favor of layer tree holder (#18901)" (#24387)" (flutter/engine#24456)
This reverts commit 89d58651ecab974f80345f065203178024eb9b84.
2021-02-17 10:44:39 -08:00
Kaushik Iska
89d58651ec Reland "Remove pipeline in favor of layer tree holder (#18901)" (flutter/engine#24387) 2021-02-16 13:27:09 -08:00
David Worsham
3215611f74 Fix use of multiple shells w/ different snapshots (flutter/engine#24152) 2021-02-03 17:42:36 -08:00
zljj0818
0ef14f3ca3 More rename from GPU thread to raster thread (flutter/engine#22819) 2020-12-03 15:03:02 -08:00
Greg Spencer
06b6f8af89 Reland: Migration to PlatformDispatcher and multi-window (flutter/engine#21932)
This re-lands #20496 and #21780 after fixing the semantics-enabling code that was causing the post-submit web_smoke_test to fail.

Below is the description from the original PR:

This is a PR for converting the dart:ui code in the engine to use a multi-window API. The goal here is to convert from the window singleton to an API that has the concept of multiple windows. Also, I'm matching up the new PlatformDispatcher class to talk directly to the PlatformConfiguration class in the engine. I'm not attempting to actually enable creating multiple windows here, just migrate to an API that has a concept of multiple windows. The multi-window API in this PR currently only ever creates one window.

The design doc for this change is here.

The major changes in this PR:

Move the platfom-specific attributes out of Window, and into the new PlatformDispatcher class that holds all of the platform state, so that the platform code need only update the configuration on this class.
Create FlutterView, FlutterWindow, and SingletonFlutterWindow classes to separate out the concepts of a view (of which there may be multiple in a window), a window (of which there may be multiple on a screen, and they host views), and a window where there is only ever expected to be one (this hosts the entire API of the former Window class, and will eventually be the type of the window singleton).
Next step after this PR lands:

Remove the Window class entirely (it is replaced by SingletonFlutterWindow). Some minor changes in the Framework are needed to switch to using SingletonFlutterWindow directly first.

The Window class still exists in this PR, but will be removed as soon as the framework is converted to point to the SingletonFlutterWindow class instead. They share the same API, just have different names (Window is currently a subclass of SingletonFlutterWindow). The intention is that the Window name will be freed up to use as a widget class name in the framework for managing windows. The singleton called window will remain, and keep the same API it has now.
2020-10-22 14:54:25 -07:00
Yuqian Li
0c645869e3 Revert "Migration to PlatformDispatcher and multi-window #20496" (flutter/engine#21792)
* Revert "Fix documentation build for window changes. (#21780)"

This reverts commit a539d91840d2fbbb4aa07eeed6a92d654db167ab.

* Revert "Migration to PlatformDispatcher and multi-window (#20496)"

This reverts commit a58fec63f196175eedfc5fbaedce9336dab5c508.
2020-10-12 19:26:41 -07:00
Greg Spencer
a58fec63f1 Migration to PlatformDispatcher and multi-window (flutter/engine#20496)
This is a PR for converting the dart:ui code in the engine to use a multi-window API. The goal here is to convert from the window singleton to an API that has the concept of multiple windows. Also, I'm matching up the new PlatformDispatcher class to talk directly to the PlatformConfiguration class in the engine. I'm not attempting to actually enable creating multiple windows here, just migrate to an API that has a concept of multiple windows. The multi-window API in this PR currently only ever creates one window.

The design doc for this change is here.

The major changes in this PR:

Move the platfom-specific attributes out of Window, and into the new PlatformDispatcher class that holds all of the platform state, so that the platform code need only update the configuration on this class.
Create FlutterView, FlutterWindow, and SingletonFlutterWindow classes to separate out the concepts of a view (of which there may be multiple in a window), a window (of which there may be multiple on a screen, and they host views), and a window where there is only ever expected to be one (this hosts the entire API of the former Window class, and will eventually be the type of the window singleton).
Next step after this PR lands:

Remove the Window class entirely (it is replaced by SingletonFlutterWindow). Some minor changes in the Framework are needed to switch to using SingletonFlutterWindow directly first.

The Window class still exists in this PR, but will be removed as soon as the framework is converted to point to the SingletonFlutterWindow class instead. They share the same API, just have different names (Window is currently a subclass of SingletonFlutterWindow). The intention is that the Window name will be freed up to use as a widget class name in the framework for managing windows. The singleton called window will remain, and keep the same API it has now.
2020-10-09 16:29:16 -07:00
Yuqian Li
9fdea6bbbc Do not remove directories in purge (flutter/engine#21478)
Otherwise, the persistent cache may hold invalid directories and make
subsequent store fail.

The newly added unit tests would fail without the fix.
2020-10-05 20:05:00 -07:00