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.
This introduces `PlatformDispatcher.implicitView`, a low-level primitive for the framework's bootstrapping. Most code, including the framework after bootstrapping, will use `View.of(context)` instead of this new API. This new primitive will let us deprecate the `window` global.
Goals:
1. **Enable multi-window**. The `PlatformDispatcher.implicitView` is nullable. If `null`, the app must create a window to get a view it can draw into.
2. **Backwards compatibility**. For "single window" apps, `PlatformDispatcher.instance.implicitView` should behave as similar to `window` as possible.
1. The `PlatformDispatcher.instance.implicitView.viewId` should be `0`.
1. The `PlatformDispatcher.instance.implicitView` must be available synchronously at root isolate startup. This allows the framework to determine if it can make single window assumptions at startup.
2. The `PlatformDispatcher.instance.implicitView` reference must not change after startup: if it is null at startup, it must always be null; if it is non-null at startup, it must always be non-null. If "single window" app enters headless mode, the implicit view must remain non-null.
In the future, the embedder will control whether an implicit view is created: mobile & legacy desktop apps will have an implicit view, multi-window desktop apps won't have an implicit view. This requires updating the engine's embedder API and is out-of-scope for this change. For now, all apps will have an implicit view.
Part of https://github.com/flutter/flutter/issues/120306
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.
* Add calls to Dart_NotifyDestroyed when the flutter view is destroyed.
* Add unit test case.
* Format.
* Ensure the destroy task runs.
* Address code review comments.
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
* Reland "dart:ui conversion from native to FfiNative" (#33116)"
This reverts commit d85395558f3d72c64d9c75e00c6ebdd5bf4583e3.
Resolves merge conflicts and updates modified/newly added
methods, and fixes the incorrect argument counts
on some of the Path methods.
Merges most (but not all) of the impeller .clang-tidy rules into the
main .clang-tidy config. Merges:
readability-identifier-naming.PrivateMemberSuffix (_)
readability-identifier-naming.EnumConstantPrefix (k)
modernize-use-default-member-init.UseAssignment
Does not merge:
readability-identifier-naming.PublicMethodCase (CamelCase)
readability-identifier-naming.PrivateMethodCase (CamelCase)
These last two are not merged due to the non-trivial number of existing
field accessors that use field_name() methods to directly return
field_name_. While these are permitted by the C++ style guide, we may
want to move to a single, simple rule and name everything in CamelCase.
These can be enabled in a followup patch.
No new tests added, since this change is style-only.
Previously, using Platform.executable (from dart:io) returned null (if
non-null-by-default was disabled) or threw an exception (if NNBD was
enabled) since we weren't setting it.
We now pass the executable name to Dart during VM startup based on the
first value in the FlutterProjectArgs::command_line_argv array passed to
FlutterEngineRun (or FlutterEngineInitialize) on startup. argv[0] (if
specified) is explicitly documented as being required to be the
executable name in embedder.h. In the case where no argv[0] is
specified, we instead set Platform.executable to "Flutter" in order to
avoid violating the (non-nullable) type annotation on
Platform.executable.
Note that dart::bin::SetExecutableName() does NOT make a copy of the
input string, so that value needs to be available for the entire lifetime
of the VM.
This also adds EmbedderConfigBuilder::SetExecutableName() to support
setting a fake executable name in unittests. By default, we continue to
set the name "embedder_unittest" unless overridden using this method.
See: https://api.flutter.dev/flutter/dart-io/Platform/executable.html
See: https://github.com/dart-lang/sdk/issues/48427
Issue: https://github.com/flutter/flutter/issues/83921