The Impeller Vulkan backend benefits from batching submission to the vk graphics queue. Managing this automatically is non-trivial and adds surprising/fragile thread based behavior, see: https://github.com/flutter/engine/pull/49870
Instead, introduce an impeller::CommandQueue object that command buffers must be submitted to in lieu of CommandBuffer->Submit, which has been made private.
TLDR
old
```c++
buffer->Submit();
```
new
```c++
context.GetQueue()->Submit({buffer});
```
The Metal and GLES implementations internally just call the private CommandBuffer->Submit, though there may be future opportunities to simplify here. The Vulkan implementation is where the meat is.
Aiks takes advantage of this by storing all command buffers on the aiks context while rendering a frame, and then performing one submit in aiks_context render. I don't think this will introduce any thread safety problems, as we don't guarantee much about aiks context - nor do we use it in a multithreaded context as far as I know.
Other tasks such as image upload still just directly submit their command buffers via the queue.
Fixes https://github.com/flutter/flutter/issues/141123
This change migrates off of the old fuchsia logging apis to use the
structured logging apis. The initial FIDL connection is made during
global initialization (before main()) and the initial minimum log level
is queried from the system. Later on, once the main loop is initialized,
we setup an async task to listen for additional log interest changes
from the system. The advantage of doing this on the main loop is that we
avoid spawning an additional background thread in the process (the
legacy logging apis use the background thread approach).
One added benefit of this change is it reduces the size of the
dart/flutter runner far packages by about 250kb in release mode, because
libsyslog.so and libbackend_fuchsia_globals.so are no longer needed.
flutter/flutter#141924
## 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
The FML_VLOG() macros are designed to use a positive integers, since
they pass -severity to the LogMessage constructor. The negative severity
can also cause some surprising behavior with log filtering. This change
update usages of FML_VLOG(-1) to FML_VLOG(1).
flutter/flutter#141924
- ImageReaderSurfaceProducer no longer drops frames when the producer and the consumers are up to two frames out of sync.
- Have the native C++ side of the Android external textures check if a new frame has been pushed and that the texture needs to be updated. This avoids having to schedule a task on the raster thread for each updated texture.
- Notify the engine earlier that a frame is needed when updating a TLHC texture.
- Re-land fix: Don't close the last dequeued from image reader until the dequeued image is no longer used.
# Description:
We're cross-compiling impeller for Android, but x86 Android targets don't have half float (`_Float16`) _ support. This change disables half float support in `impeller/geometry/half.h` for platforms where the `_Float16` builtin is lacking.
As can be seen in `half.h`, `Float16` support is enabled for all non-windows platforms, which doesn't not allow our use case.
# Issues
I can't seem to find a way to file an issue describing this, but
- [] 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.
[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
DisplayList by default contains Skia paths stored as `SkPath` objects. Impeller must convert these to its internal `impeller::Path` format on every dispatch of the DisplayList on every frame.
This change allows Impeller to store a cached copy of its version of the path into the DisplayList and reuse that instance if it ever encounters the same DisplayList again (likely to happen as most paths come from the Framework which does a lot of work to re-use ui.Picture objects - i.e. DisplayLists).
In order to facilitate this change, `impeller::Path` was modified to have fast-copy-constructors that share the data and the PathBuilder will copy the mutable data into an immutable version in `TakePath()`.
Reverts flutter/engine#50028
Initiated by: jonahwilliams
This change reverts the following previous change:
Original Description:
Once a hardware buffer has been imported (a VkImage created for it), we don't ever need to re-create a VkImage, even when the contents change. The same hardware buffer can be identified by ID. Part of https://github.com/flutter/flutter/issues/142153
Otherwise we spend a lot of time re-creating VkImages:

Draft is here, but is currently leaky: https://github.com/flutter/engine/pull/50028
We only need something like a LRU with the max image size (seems to be 3 for me). This does log locally that I'm not calling close correctly:
```
E/flutter ( 5580): [ERROR:flutter/shell/platform/android/image_external_texture_vk.cc(51)] Size: 3
W/System ( 5580): A resource failed to call HardwareBuffer.close.
W/System ( 5580): A resource failed to call HardwareBuffer.close.
W/System ( 5580): A resource failed to call HardwareBuffer.close.
W/System ( 5580): A resource failed to call HardwareBuffer.close.
W/System ( 5580): A resource failed to call HardwareBuffer.close.
W/System ( 5580): A resource failed to call HardwareBuffer.close.
W/System ( 5580): A resource failed to call HardwareBuffer.close.
W/System ( 5580): A resource failed to call HardwareBuffer.close.
W/System ( 5580): A resource failed to call HardwareBuffer.close.
W/System ( 5580): A resource failed to call HardwareBuffer.close.
W/System ( 5580): A resource failed to call HardwareBuffer.close.
W/System ( 5580): A resource failed to call HardwareBuffer.close.
W/System ( 5580): A resource failed to call HardwareBuffer.close.
W/System ( 5580): A resource failed to call HardwareBuffer.close.
W/System ( 5580): A resource failed to call HardwareBuffer.close.
W/System ( 5580): A resource failed to call HardwareBuffer.close.
W/System ( 5580): A resource failed to call HardwareBuffer.close.
W/System ( 5580): A resource failed to call HardwareBuffer.close.
W/System ( 5580): A resource failed to call HardwareBuffer.close.
W/System ( 5580): A resource failed to call HardwareBuffer.close.
W/System ( 5580): A resource failed to call HardwareBuffer.close.
W/System ( 5580): A resource failed to call HardwareBuffer.close.
```
FYI @johnmccutchan
Once a hardware buffer has been imported (a VkImage created for it), we don't ever need to re-create a VkImage, even when the contents change. The same hardware buffer can be identified by ID. Part of https://github.com/flutter/flutter/issues/142153
Otherwise we spend a lot of time re-creating VkImages:

Draft is here, but is currently leaky: https://github.com/flutter/engine/pull/50028
We only need something like a LRU with the max image size (seems to be 3 for me). This does log locally that I'm not calling close correctly:
```
E/flutter ( 5580): [ERROR:flutter/shell/platform/android/image_external_texture_vk.cc(51)] Size: 3
W/System ( 5580): A resource failed to call HardwareBuffer.close.
W/System ( 5580): A resource failed to call HardwareBuffer.close.
W/System ( 5580): A resource failed to call HardwareBuffer.close.
W/System ( 5580): A resource failed to call HardwareBuffer.close.
W/System ( 5580): A resource failed to call HardwareBuffer.close.
W/System ( 5580): A resource failed to call HardwareBuffer.close.
W/System ( 5580): A resource failed to call HardwareBuffer.close.
W/System ( 5580): A resource failed to call HardwareBuffer.close.
W/System ( 5580): A resource failed to call HardwareBuffer.close.
W/System ( 5580): A resource failed to call HardwareBuffer.close.
W/System ( 5580): A resource failed to call HardwareBuffer.close.
W/System ( 5580): A resource failed to call HardwareBuffer.close.
W/System ( 5580): A resource failed to call HardwareBuffer.close.
W/System ( 5580): A resource failed to call HardwareBuffer.close.
W/System ( 5580): A resource failed to call HardwareBuffer.close.
W/System ( 5580): A resource failed to call HardwareBuffer.close.
W/System ( 5580): A resource failed to call HardwareBuffer.close.
W/System ( 5580): A resource failed to call HardwareBuffer.close.
W/System ( 5580): A resource failed to call HardwareBuffer.close.
W/System ( 5580): A resource failed to call HardwareBuffer.close.
W/System ( 5580): A resource failed to call HardwareBuffer.close.
W/System ( 5580): A resource failed to call HardwareBuffer.close.
```
FYI @johnmccutchan
Closes https://github.com/flutter/flutter/issues/133415.
This includes a performance optimization for the runner itself, where
`--include=...`s are used as a base to check, versus checking _every_
file and seeing if it exists in a list. This works better with what is
expected in `ci/bin/format.dart` without any contract change.
Also added a few more functional tests of the system.
Changes since last roll
```
58665e3dee4 Version 3.4.0-79.0.dev
6b0b4d425b0 Macro. Keep FileState for macro file, refresh if its content changes.
f4c3572c18a [deps] Rev `native` packages.
f4dae883559 [co19] Roll co19 to af2ac968c0ca28b7dd94325b00a3acf569f6e858
e2aac0b8e86 [web docs] add package:web to the main sdk docs - api.dart.dev
3d4a39e9c24 Revert "Revert two CLs that remove WithoutNullSafetyMixin usages."
20a27fee111 Fix for data driven rename when class is used in as expression
ecb5fc2228a [dart2wasm] Improve dispatch table packing from 49% to 99%
cdad90dfb81 [frontend_server] frontend_server_flutter_suite
```
Requires manual roll due to ffi package move as part of `f4c3572c18a`.
Adds two new APIs that insert memory barriers for compute -> compute dependencies.
```c++
// |ComputePass|
void AddBufferMemoryBarrier() override;
// |ComputePass|
void AddTextureMemoryBarrier() override;
```
Also makes the ComputePassVK automatically insert a compute -> vertex dependency when encoding. This change is sufficient to let the GPU compute implementation of draw points work on Pixel and Samsung Android devices.
For more explaination on these specific barriers, see the documentation added in this PR.
Fixes https://github.com/flutter/engine/pull/49946
Closes https://github.com/flutter/flutter/issues/133415.
---
This is a prototype I threw together in about 1-2 hours. It enforces and
automatically fixes header guards that don't match the [the Google C++
style
guide](https://google.github.io/styleguide/cppguide.html#The__define_Guard).
For example, here is (trimmed) output at HEAD:
```txt
line 5, column 1 of impeller/aiks/picture.h: Unexpected #pragma once
╷
5 │ #pragma once
│ ^^^^^^^^^^^^
╵
line 5, column 1 of flow/stopwatch.h: Expected #ifndef FLUTTER_FLOW_STOPWATCH_H_
╷
5 │ #ifndef FLUTTER_FLOW_INSTRUMENTATION_H_
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
╵
The following 731 files have invalid header guards:
```
When a view gets disposed of, its rasterizer completely clears up the singleton `PlatformViewManager`. Particularly, it removes all registered platform view factories.
This is wrong because the remaining PlatformViews on the page cannot be re-rendered, and the default Platform View factories (used by `pointer_interceptor`, for example), disappear.
This PR attempts to preserve the `dispose` logic of the canvaskit rasterizer, without using the `debugClear` method of the `PlatformViewManager` (which is supposedly test-only).
## Issues
* Fixes https://github.com/flutter/flutter/issues/142094
## Tests
* Added unit-test
* Deployed demo app: https://dit-maps-tests.web.app
[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
Generated by https://github.com/flutter/engine/pull/48903 (`dart ./tools/header_guard_check/bin/main.dart --fix`).
As discussed with @cbracken and @jmagman, the guards are not technically needed on the Mac/iOS code, but they (a) do not hurt and (b) still provide value if for some reason `#include` is used instead of `#import` (though I suspect we could try to add that to the tool in the future as well).
Fixes https://github.com/flutter/flutter/issues/141571
Shell::Screenshot was impelemnted in a Skia-only way and would crash when invoked. Adds test coverage for the breaking path on iOS that ends up calling `FlutterView drawLayer`.
Adds a Dart API so Application/Plugin programmers can retrieve the `initialData` configuration value that may be passed when adding a view from JS in a multiViewEnabled app.
When adding a view to an app like this:
```js
flutterApp.addView({
hostElement: someElement,
initialData: {
randomUUID: globalThis.crypto.randomUUID(),
}
});
```
`initialData` can be accessed from Dart by defining a JS-interop class like:
```dart
import 'dart:js_interop';
// The JS-interop definition of the `initialData` object passed to the views of this app.
@JS()
@staticInterop
class InitialData {}
/// The attributes of the [InitialData] object.
extension InitialDataExtension on InitialData {
external String? get randomUUID;
}
```
And then, from the code of the application:
```dart
...
Widget build(BuildContext context) {
final int viewId = View.of(context).viewId;
final InitialData? data = ui_web.views.getInitialData(viewId) as InitialData?;
return Text('${data?.randomUUID}');
}
...
```
## Testing
Will add unit tests once naming is sorted out :)
[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style