5898 Commits

Author SHA1 Message Date
Loïc Sharma
e1b38345d3 [Windows] Add/remove view failures should not hang (flutter/engine#52164)
If the embedder API's `FlutterEngineAddView` and `FlutterEngineRemoveView` don't return `kSuccess`, their callbacks won't be invoked. See: [flutter.dev/go/multi-view-embedder-apis](https://flutter.dev/go/multi-view-embedder-apis).

Previously, the Windows embedder would hang in this scenario as it blocks until the callbacks are invoked. Now, the Windows embedder only blocks if these embedder APIs return `kSuccess`.

Kudos to @dkwingsmt for catching this!

Part of https://github.com/flutter/flutter/issues/144810
Part of https://github.com/flutter/flutter/issues/142845

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-04-17 16:44:28 +00:00
Matej Knopp
4eb6676253 [macOS] FlutterSurfaceManager should not return surfaces that are in use (flutter/engine#52082)
Fixes https://github.com/flutter/flutter/issues/138936

Currently the engine hold a single backbuffer per flutter view layer,
which gets swapped with front buffer. This however is too optimistic, as
the front buffer in some cases might not get immediately picked up by
the compositor. When that happens, during next frame the cache may
return a backbuffer that is in fact still being used by the compositor.
Rendering to such surface will result in artifacts seen in the video.
This seems more likely to happen with busy platform thread. It is also
more likely to happen with the presence of "heavy" platform views such
as `WKWebView`.

IOSurface is able to report when it is being used by the compositor
(`IOSurfaceIsInUse`). This PR ensures that the backing store cache never
returns surface that is being used by compositor. This may result in
transiently keeping more surfaces than before, as the compositor
sometimes seems to holds on to the surface longer than it is displayed,
but that's preferable outcome to visual glitches.

This PR adds `age` field to `FlutterSurface`. When returning buffers to
the surface cache (during compositor commit), the age of each surface
currently present in cache increases by one, while the newly returned
surfaces have their age set to 0.

When returning surfaces from cache, a surface with lowest age that is
not in use by compositor is returned.

Surfaces with age that reaches 30 are evicted from the pool. Reaching
this age means one of two things:
- When surface is still in use at age 30 it means the compositor is
holding on to it much longer than we expect. In this case just forget
about the surface, we can't really do anything about it.
- When surface is not in use at age 30, it means it hasn't been removed
from cache for 29 subsequent frames. That means the cache is holding more
surfaces than needed.

Removing all surfaces from cache after idle period remains unchanged.

Before: 


https://github.com/flutter/engine/assets/96958/ba2bfc43-525e-4a88-b37c-61842994d3bc

After:


https://github.com/flutter/engine/assets/96958/8b5d393e-3031-46b1-b3f0-cb7f63f8d960


*If you had to change anything in the [flutter/tests] repo, include a
link to the migration guide as per the [breaking change policy].*

## 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
2024-04-17 15:22:20 +02:00
Matej Knopp
0dc6ed3af1 [macOS] FlutterView should not override platform view cursor (flutter/engine#52159)
This fixes an edge case that I've overlooked in
https://github.com/flutter/engine/pull/43101.

It is possible to configure `FlutterViewController` tracking area with
`FlutterMouseTrackingModeAlways` option, in which case the tracking area
will call `[FlutterView cursorUpdate:]` unconditionally even if the
mouse cursor is over platform view and the platform view has already
handled the mouse update.

The solution is to prevent the `FlutterView` from updating the cursor
when the cursor is over a platform view. This can be accomplished by
doing a hitTest inside `[FlutterView cursorUpdate:]`.

## 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
2024-04-17 15:17:53 +02:00
Matej Knopp
ef0bc66c15 [macOS] Handle reparenting platform views (flutter/engine#52152)
Fixes https://github.com/flutter/flutter/issues/146810

This handles situation where the platform view reparents and replaces
itself with a placeholder view. This commonly happens with WKWebView
entering full screen.

## 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
2024-04-17 13:05:38 +02:00
Jenn Magder
63e75efc51 Migrate FlutterChannelKeyResponder and FlutterSpellCheckPlugin to ARC (flutter/engine#52148)
Clean up headers in FlutterChannelKeyResponder and FlutterSpellCheckPlugin.  Migrate to ARC.

Move `FlutterSpellCheckResult` interface into the .mm since it's only used there.

Part of https://github.com/flutter/flutter/issues/137801.
Blocked by https://github.com/flutter/engine/pull/51633 `FlutterUIPressProxy`
2024-04-16 23:50:14 +00:00
Jenn Magder
05201a8018 Migrate FlutterUIPressProxy, ios_context*, rendering_api_selection, and a few other files to ARC (flutter/engine#51633)
Smart pointers support ARC as of https://github.com/flutter/engine/pull/47612, and the unit tests were migrated in https://github.com/flutter/engine/pull/48162.

Migrate some files from MRC to ARC.  These files do not themselves import any MRC files, only ARC-ified files like `FlutterMetalLayer.h`, making them leaf nodes in the dependency graph of MRC files.  Just doing a few at a time to make the dependency graph manageable, and to easily revert if this causes retain cycles or other memory management issues.

Part of https://github.com/flutter/flutter/issues/137801.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-04-16 21:45:50 +00:00
Jason Simmons
50771f3ad4 Roll reclient, libpng, and zlib (flutter/engine#52072)
Based on https://github.com/flutter/engine/pull/52067
2024-04-16 18:31:30 +00:00
Jenn Magder
5f95d3b108 Migrate vsync_waiter_ios to ARC (flutter/engine#52104)
Smart pointers support ARC as of https://github.com/flutter/engine/pull/47612, and the unit tests were migrated in https://github.com/flutter/engine/pull/48162.

Migrate `vsync_waiter_ios`  from MRC to ARC.

Part of https://github.com/flutter/flutter/issues/137801.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-04-16 06:01:08 +00:00
gaaclarke
e359708723 Relands "[Impeller] moved to bgra10_xr (#52019)" (flutter/engine#52142)
relands https://github.com/flutter/engine/pull/52019

Patch addresses the compilation problem noted in https://github.com/flutter/engine/pull/52019#issuecomment-2058006113

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-04-16 00:59:09 +00:00
Jonah Williams
9c212d5d0d [iOS] allow enabling asserts from Plist. (flutter/engine#52069)
Part of https://github.com/flutter/flutter/issues/145729 .

I don't believe (or wasn't able to find ) if there is a way to specify dart-vm flags from an iOS application. Once its installed, the tool provided process args won't work. By allowing this to be specified in the Plist, developers can ensure the value persists for subsequent launches.
2024-04-16 00:06:05 +00:00
Jenn Magder
2d3cce14a1 Migrate FlutterDartVMServicePublisher to ARC (flutter/engine#52081)
Smart pointers support ARC as of https://github.com/flutter/engine/pull/47612, and the unit tests were migrated in https://github.com/flutter/engine/pull/48162.

Migrate `FlutterDartVMServicePublisher` from MRC to ARC.  I validated `flutter attach` works on this engine PR, so the VM service URL is being advertised and the tool is discovering it.

Part of https://github.com/flutter/flutter/issues/137801.
2024-04-15 23:55:27 +00:00
auto-submit[bot]
b4bad7f256 Reverts "[Impeller] moved to bgra10_xr (#52019)" (flutter/engine#52140)
Reverts: flutter/engine#52019
Initiated by: jonahwilliams
Reason for reverting: I believe the tree failures are due to changes in the build configuration this file introduced.
Original PR Author: gaaclarke

Reviewed By: {jonahwilliams}

This change reverts the following previous change:
fixes https://github.com/flutter/flutter/issues/145933

This required that we moved the golden image tests to arm64 since the wide gamut tests would now require BGRA10_XR and that's only available to arm64.

tests: in framework repo https://github.com/flutter/flutter/tree/master/dev/integration_tests/wide_gamut_test. There was a test added to that suite specifically for this case when we turned off BGRA10_XR the first time.

This has a dependency on https://github.com/flutter/engine/pull/51998 which includes the necessary skia change.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-04-15 22:50:46 +00:00
gaaclarke
47ad73b01c [Impeller] moved to bgra10_xr (flutter/engine#52019)
fixes https://github.com/flutter/flutter/issues/145933

This required that we moved the golden image tests to arm64 since the wide gamut tests would now require BGRA10_XR and that's only available to arm64.

tests: in framework repo https://github.com/flutter/flutter/tree/master/dev/integration_tests/wide_gamut_test. There was a test added to that suite specifically for this case when we turned off BGRA10_XR the first time.

This has a dependency on https://github.com/flutter/engine/pull/51998 which includes the necessary skia change.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-04-15 18:03:51 +00:00
Jenn Magder
31f79201a8 Migrate FlutterCallbackCache and FlutterKeyboardManager to ARC (flutter/engine#51983)
Smart pointers support ARC as of https://github.com/flutter/engine/pull/47612, and the unit tests were migrated in https://github.com/flutter/engine/pull/48162.

Migrate`FlutterCallbackCache` and `FlutterKeyboardManager` from MRC to ARC.  These files do not themselves import any MRC files, making them leaf nodes in the dependency graph of MRC files.  

Doing a few at a time to make the dependency graph manageable, and to easily revert if this causes retain cycles or other memory management issues.

Part of https://github.com/flutter/flutter/issues/137801.
2024-04-15 17:58:05 +00:00
Jonah Williams
0951e43921 [scenarios] test disabling surface clear. (flutter/engine#52128)
I suspect that the change to clear the surface is the result of the
scenario app instability. just a guess: the screenshots looks like we're
missing the platform view. maybe the clearing of the surface is causing
an extra frame to be pushed. That frame is getting picked up in the
golden due to a race condition that is hard to hit locally


Testing disabling of this functionality in the golden test. If this pass
a real fix involves some sort of hook into the rendering to verify it
has fully completed before screenshotting.
2024-04-15 10:25:20 -07:00
Loïc Sharma
c17e21a794 [Windows] Refactor client wrapper to prepare for multi-view (flutter/engine#52073)
_This is a refactoring with no semantic changes. No new public APIs are introduced by this change._

In the future, a new constructor will be added to `FlutterViewController` to allow it to use an existing `std::shared_ptr<FlutterEngine>` to create the view controller. This updates `FlutterViewController` to store a `std::shared_ptr` and other minor tweaks.

For context, we plan to not land the new multi-window `FlutterViewController` constructor until Window's multi-window support is productionized. Until then, we will maintain a [patch](https://github.com/flutter/flutter/issues/143767#issuecomment-2050741185) for folks that want to experiment with multi-window. This change makes that patch as small as possible.

Design doc: [flutter.dev/go/desktop-multi-view-runner-apis](https://flutter.dev/go/desktop-multi-view-runner-apis)

Part of https://github.com/flutter/flutter/issues/143767
Part of https://github.com/flutter/flutter/issues/142845

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-04-12 21:45:30 +00:00
Jenn Magder
30569dc07a Migrate FlutterEmbedderKeyResponder to ARC (flutter/engine#52048)
Smart pointers support ARC as of https://github.com/flutter/engine/pull/47612, and the unit tests were migrated in https://github.com/flutter/engine/pull/48162.

Migrate `FlutterEmbedderKeyResponder` from MRC to ARC.  Clean up some header imports which made this seem like it depended on not-yet-migrated MRC files.

Part of https://github.com/flutter/flutter/issues/137801.
2024-04-12 20:09:04 +00:00
Jason Simmons
ad5a851612 Fix the Dart language version for Fuchsia's build of the args package (flutter/engine#52083)
This is required for the next Dart roll (see
https://github.com/flutter/engine/pull/52077)
2024-04-12 12:39:14 -07:00
Jenn Magder
f2152f1e0d Update iOS KeyCodeMap dictionary literal and migrate to ARC (flutter/engine#51981)
Framework template updated in https://github.com/flutter/flutter/pull/146481.  See [gen_keycodes README](https://github.com/flutter/flutter/tree/master/dev/tools/gen_keycodes ) for details.

Fixes https://github.com/flutter/flutter/issues/146480 `-Wobjc-redundant-literal-use` error.

Note `-Wobjc-redundant-literal-use` is already on for clang-tidy 
3e5e40c10a/.clang-tidy (L13) but in this case it's only true triggered when the file is compiled with ARC.  When I migrated this file to ARC as part of https://github.com/flutter/flutter/issues/137801, it triggered the error.
2024-04-11 23:59:24 +00:00
Jason Simmons
6674f823cf Clear the surface to transparent black when creating a PlatformViewWrapper (flutter/engine#52047)
Without this, an opaque black surface may briefly flash onscreen when the platform view is shown (see internal issue b/332379081)

This matches the behavior used before to the introduction of PlatformViewRenderTarget in b3945f7706

That commit moved the clearing of the surface into SurfaceTexturePlatformViewRenderTarget.  But that caused surface clearing to happen in scenarios where there was no PlatformViewWrapper, resulting in the issue seen in https://github.com/flutter/flutter/issues/141068

Later the surface clearing was removed from SurfaceTexturePlatformViewRenderTarget, causing the flashing black screen.
2024-04-11 22:05:33 +00:00
Tong Mu
dc82dbb0b9 Move Shell::Add/RemoveView to PlatformView and refine embedder API doc (flutter/engine#52003)
This PR moves the methods to add or remove views from `Shell` to
`PlatformView`. By design, the `Shell` is supposed to be a messenger
that glues classes together, while `PlatformView` is the operator that
embedders that do not use the embedder API should operate on. The
current design was made due to lack of knowledge to this design.

This also makes `PlatformView` aware of views, which might be a
prerequisite to https://github.com/flutter/engine/pull/51925.

This PR also adds some details to embedder API `AddView` and
`RemoveView`.

## Pre-launch Checklist

- [ ] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [ ] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [ ] I read and followed the [Flutter Style Guide] and the [C++,
Objective-C, Java style guides].
- [ ] 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 the PR is [test-exempt]. See [testing the engine] for
instructions on writing and running engine tests.
- [ ] I updated/added relevant documentation (doc comments with `///`).
- [ ] I signed the [CLA].
- [ ] 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
2024-04-11 13:26:24 -07:00
巢鹏
b935b22302 [Fuchsia] Support per app present latency tracing (flutter/engine#51503)
Bug: http://b/323408867
2024-04-11 16:19:21 -04:00
Jason Simmons
e5d0cae6cd Save and restore OpenGL bindings that are changed by fl_renderer_render (flutter/engine#51887)
fl_renderer_render uses the raster thread GL context that is also used by Skia.  Skia expects that its bindings have not been changed elsewhere.
2024-04-11 19:39:03 +00:00
Loïc Sharma
623bc22647 [Windows] Allow adding/removing views (flutter/engine#51923)
This enables the Windows embedder to render to multiple views using the new `FlutterEngineAddView` and `FlutterEngineRemoveView` embedder APIs. See: https://flutter.dev/go/multi-view-embedder-apis
 
Prepares for https://github.com/flutter/flutter/issues/144810
Part of https://github.com/flutter/flutter/issues/142845

### Sync over async

Windows expects synchronous operations: windows are created, resized, and destroyed synchronously. However, Flutter native is asynchronous due to its [threading model](https://github.com/flutter/flutter/wiki/The-Engine-architecture#threading).

This change blocks the platform thread when a non-implicit view is added or removed. See: https://flutter.dev/go/multi-view-sync-over-async

### Synchronization

The embedder and engine have separate view states that they synchronize asynchronously. The engine can present a view on the raster thread while the embedder is destroying that same view on the platform thread. This change introduces a mutex to protect against this:

1. The platform thread acquires a **shared** lock whenever it needs to access the view.
2. The platform thread acquires an **exclusive** lock to add a view to the embedder, _before_ it notifies the engine of the view
3. The platform thread acquires an **exclusive** lock to remove a view from the embedder, *after* the engine has acknowledged the view's removal but *before* the embedder destroys the view.
4. The raster thread acquires a **shared** lock to present to a view. This lock is held for the entirety of the present operation, thereby blocking the platform thread from destroying the view.

The implicit view is an important corner case. The framework/engine believe the implicit view **always** exists, even if the app is in headless mode. The embedder does not notify the engine when it destroys the implicit view. In other words, the embedder must safely ignore presents to the implicit view when it does not exist.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-04-11 16:10:04 +00:00
yaakovschectman
5b9fd62cb4 Composite multiple layers in Windows software rendering (flutter/engine#51759)
Blend pixels per-alpha when presenting multiple layers from the software
compositor.

Part of https://github.com/flutter/flutter/issues/143375

## 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 `///`).
- [ ] 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

---------

Co-authored-by: Loïc Sharma <737941+loic-sharma@users.noreply.github.com>
2024-04-11 10:25:27 -04:00
Jonah Williams
1c2ffb9b30 [Engine] allow --enable-asserts flag to be passed to dart vm in profile mode. (flutter/engine#52029)
Allows https://github.com/flutter/flutter/issues/145729
2024-04-10 21:53:52 +00:00
Jenn Magder
3cd96ea83c Migrate FlutterRestorationPlugin, FlutterTextureRegistryRelay, FlutterScreenAndSceneIfLoaded to ARC (flutter/engine#51984)
Smart pointers support ARC as of https://github.com/flutter/engine/pull/47612, and the unit tests were migrated in https://github.com/flutter/engine/pull/48162.

Migrate `FlutterRestorationPlugin`, `FlutterTextureRegistryRelay`, and `UIViewController+FlutterScreenAndSceneIfLoaded` from MRC to ARC.  These files do not themselves import any MRC files, making them leaf nodes in the dependency graph of MRC files.  

Doing a few at a time to make the dependency graph manageable, and to easily revert if this causes retain cycles or other memory management issues.

Part of https://github.com/flutter/flutter/issues/137801.
2024-04-10 21:53:51 +00:00
Jonah Williams
53c05184b1 [Android] post image task to main handler. (flutter/engine#52025)
Fixes https://github.com/flutter/flutter/issues/146465
2024-04-10 19:43:23 +00:00
auto-submit[bot]
c0bd2a3ce0 Reverts "Delete engine v1 android embedding (#51229)" (flutter/engine#51996)
Reverts: flutter/engine#51229
Initiated by: gmackall
Reason for reverting: blocking engine->framework roll (I missed some framework code referencing the v1 embedding).
Original PR Author: gmackall

Reviewed By: {matanlurey, reidbaker}

This change reverts the following previous change:
Fixes https://github.com/flutter/flutter/issues/143531

Also fixes a random typo I found

~TODO to test this~ (no more todo):
-~test the framework against this as well, probably with a dummy PR changing the engine commit to my branch if this is possible~ not possible, made a best effort removal of framework code in https://github.com/flutter/flutter/pull/144726.
-~figure out if the old embedding is used in g3 at all~ removed all uses
-~figure out exactly what the ShimPluginRegistry/ShimRegistrar are doing, and if fully deleting them was right~ (see https://github.com/flutter/engine/pull/51229#issuecomment-1981757743)

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-04-09 19:13:47 +00:00
Gray Mackall
797e1ad902 Delete engine v1 android embedding (flutter/engine#51229)
Fixes https://github.com/flutter/flutter/issues/143531

Also fixes a random typo I found

TODO to test this:
-test the framework against this as well, probably with a dummy PR changing the engine commit to my branch if this is possible
-figure out if the old embedding is used in g3 at all
-~figure out exactly what the ShimPluginRegistry/ShimRegistrar are doing, and if fully deleting them was right~ (see https://github.com/flutter/engine/pull/51229#issuecomment-1981757743)

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-04-09 18:03:17 +00:00
Jason Simmons
f745408809 Move the Dart SDK to //flutter/third_party/dart (flutter/engine#51917) 2024-04-09 12:48:09 +00:00
Matej Knopp
8796ecd15c [macOS] Implement hit testing and handle platform view cursor changes (flutter/engine#43101)
Fixes https://github.com/flutter/flutter/issues/129085

## Changes to `FlutterMouseCursorPlugin`

- `none` cursor is not handled by hiding the cursor anymore. That was
too big of a hammer as it also affects other views (and platform views).
Instead empty cursor is created from empty `NSImage`.

- Cursor plugin now notifies the engine when cursor has changed. The
engine forwards the change to last `FlutterView` that handled mouse
event. This is necessary because on occasion `FlutterView` needs to be
able to restore cursor without framework being involved.

## Preventing PlatformView from changing cursor when it is obscured by
Flutter Content.

Generally in Cocoa cursor changes are done as response to `mouseMoved`
event, which is driven by a `NSTrackingArea`. The issue here is that
this is not affected by hit testing and tracking areas form a hierarchy
parallel to view hierarchy and are not affected by being obscured by
another view (or tracking area). This means that platform view will
receive `mouseMoved` event even when is obscured by Flutter content. To
work around this, the mutator view puts a tracking area above platform
view, which means it gets the mouseMove event first, and when it decides
that mouse is over Flutter content, it will prevent platform view from
changing the cursor for the rest of RunLoop turn (see
`NSCursor+IgnoreChange`).

## Actual hit testing

This part is rather straightforward, the area where FlutterContent
obscures mutator view is provided to the mutator view, which will return
`nil` from `hitTest:` when the point is in the obscured area.

## Example of hit testing


https://github.com/flutter/engine/assets/96958/bbac0cfd-8c44-44d3-addd-921c91a8a539

## 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 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
2024-04-09 12:00:42 +02:00
Jenn Magder
6ff8c03a4b Remove #if SHELL_ENABLE_METAL checks in darwin code (flutter/engine#51947)
Same as https://github.com/flutter/engine/pull/51636 except:

1. The original change caused scuba changes because those simulators are running on Macs without GPU passthrough, and so fallback to software rendering when `MTLCreateSystemDefaultDevice()` fails.  Re-add that `MTLCreateSystemDefaultDevice` check

https://github.com/flutter/engine/pull/51636/files#diff-1db60a8a74c1cfb40c970541dd1f7f0f6301853a2ba17451f5117f154036d732L22-L31

2. Set `enable_metal` to always true for `macos/BUILD.gn`
 
[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-04-08 22:25:01 +00:00
Zachary Anderson
5f5f524f33 Run local_engine.json builds in prod (flutter/engine#51931)
Finishes part 2 of https://github.com/flutter/flutter/issues/145263.

This required fixing a python script to use the version of Java obtained
through the DEPS file rather than one assumed to exist in the
environment.
2024-04-08 13:01:42 -07:00
Jason Simmons
209b89244a Use the AOT snapshot built by the Dart SDK for the frontend server (flutter/engine#51943)
Dart will be removing the frontend server JIT snapshot.
(see https://dart.googlesource.com/sdk/+/e6c9eaaf6b63e5d3d0eefd7e95df9d10d9a25569)
2024-04-08 18:38:03 +00:00
Tong Mu
694f9469bf Fix a memory error in a multithreaded test (flutter/engine#51951)
The culprit test asks different threads to access some stack variables, but the stack might return earlier than the threads' completion. This PR fixes it by adding latches.

This test, despite being possibly fine for now, consistently triggers the following asan error when I make some unrelated trivial changes.

The thrown error:
<details>
<pre>
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from EmbedderTest
[ RUN      ] EmbedderTest.EmbedderThreadHostUseCustomThreadConfig
=================================================================
==14398==ERROR: AddressSanitizer: stack-use-after-scope on address 0x00031833b530 at pc 0x00013248d543 bp 0x000318740390 sp 0x00031873fb58
WRITE of size 4 at 0x00031833b530 thread T2
    #0 0x13248d542 in pthread_getschedparam+0x3d2 (libclang_rt.asan_osx_dynamic.dylib:x86_64+0x2c542)
    #1 0x100577671 in flutter::testing::EmbedderTest_EmbedderThreadHostUseCustomThreadConfig_Test::TestBody()::$_0::operator()() const+0x1a1 (embedder_unittests:x86_64+0x10030b671)
    #2 0x1005774a2 in decltype(std::declval<flutter::testing::EmbedderTest_EmbedderThreadHostUseCustomThreadConfig_Test::TestBody()::$_0&>()()) std::_fl::__invoke[abi:v15000]<flutter::testing::EmbedderTest_EmbedderThreadHostUseCustomThreadConfig_Test::TestBody()::$_0&>(flutter::testing::EmbedderTest_EmbedderThreadHostUseCustomThreadConfig_Test::TestBody()::$_0&)+0x22 (embedder_unittests:x86_64+0x10030b4a2)
    #3 0x100577402 in void std::_fl::__invoke_void_return_wrapper<void, true>::__call<flutter::testing::EmbedderTest_EmbedderThreadHostUseCustomThreadConfig_Test::TestBody()::$_0&>(flutter::testing::EmbedderTest_EmbedderThreadHostUseCustomThreadConfig_Test::TestBody()::$_0&)+0x22 (embedder_unittests:x86_64+0x10030b402)
    #4 0x1005773ba in std::_fl::__function::__alloc_func<flutter::testing::EmbedderTest_EmbedderThreadHostUseCustomThreadConfig_Test::TestBody()::$_0, std::_fl::allocator<flutter::testing::EmbedderTest_EmbedderThreadHostUseCustomThreadConfig_Test::TestBody()::$_0>, void ()>::operator()[abi:v15000]()+0x2a (embedder_unittests:x86_64+0x10030b3ba)
    #5 0x1005734f6 in std::_fl::__function::__func<flutter::testing::EmbedderTest_EmbedderThreadHostUseCustomThreadConfig_Test::TestBody()::$_0, std::_fl::allocator<flutter::testing::EmbedderTest_EmbedderThreadHostUseCustomThreadConfig_Test::TestBody()::$_0>, void ()>::operator()()+0x26 (embedder_unittests:x86_64+0x1003074f6)
    #6 0x10066a525 in std::_fl::__function::__value_func<void ()>::operator()[abi:v15000]() const+0x105 (embedder_unittests:x86_64+0x1003fe525)
    #7 0x10066a3f2 in std::_fl::function<void ()>::operator()() const+0x22 (embedder_unittests:x86_64+0x1003fe3f2)
    #8 0x100c229dc in fml::MessageLoopImpl::FlushTasks(fml::FlushType)+0x37c (embedder_unittests:x86_64+0x1009b69dc)
    #9 0x100c22577 in fml::MessageLoopImpl::RunExpiredTasksNow()+0x27 (embedder_unittests:x86_64+0x1009b6577)
    #10 0x100c8aa2f in fml::MessageLoopDarwin::OnTimerFire(__CFRunLoopTimer*, fml::MessageLoopDarwin*)+0x2f (embedder_unittests:x86_64+0x100a1ea2f)
    #11 0x7ff817b54508 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__+0x13 (CoreFoundation:x86_64+0x97508)
    #12 0x7ff817b540b8 in __CFRunLoopDoTimer+0x310 (CoreFoundation:x86_64+0x970b8)
    #13 0x7ff817b53ce9 in __CFRunLoopDoTimers+0x11c (CoreFoundation:x86_64+0x96ce9)
    #14 0x7ff817b380ac in __CFRunLoopRun+0x83b (CoreFoundation:x86_64+0x7b0ac)
    #15 0x7ff817b372a8 in CFRunLoopRunSpecific+0x22c (CoreFoundation:x86_64+0x7a2a8)
    #16 0x100c8b155 in fml::MessageLoopDarwin::Run()+0x305 (embedder_unittests:x86_64+0x100a1f155)
    #17 0x100c223d0 in fml::MessageLoopImpl::DoRun()+0x150 (embedder_unittests:x86_64+0x1009b63d0)
    #18 0x100c1f1fa in fml::MessageLoop::Run()+0x2a (embedder_unittests:x86_64+0x1009b31fa)
    #19 0x100c7baa4 in fml::Thread::Thread(std::_fl::function<void (fml::Thread::ThreadConfig const&)> const&, fml::Thread::ThreadConfig const&)::$_0::operator()() const+0x194 (embedder_unittests:x86_64+0x100a0faa4)
    #20 0x100c7b8e2 in decltype(std::declval<fml::Thread::Thread(std::_fl::function<void (fml::Thread::ThreadConfig const&)> const&, fml::Thread::ThreadConfig const&)::$_0&>()()) std::_fl::__invoke[abi:v15000]<fml::Thread::Thread(std::_fl::function<void (fml::Thread::ThreadConfig const&)> const&, fml::Thread::ThreadConfig const&)::$_0&>(fml::Thread::Thread(std::_fl::function<void (fml::Thread::ThreadConfig const&)> const&, fml::Thread::ThreadConfig const&)::$_0&)+0x22 (embedder_unittests:x86_64+0x100a0f8e2)
    #21 0x100c7b842 in void std::_fl::__invoke_void_return_wrapper<void, true>::__call<fml::Thread::Thread(std::_fl::function<void (fml::Thread::ThreadConfig const&)> const&, fml::Thread::ThreadConfig const&)::$_0&>(fml::Thread::Thread(std::_fl::function<void (fml::Thread::ThreadConfig const&)> const&, fml::Thread::ThreadConfig const&)::$_0&)+0x22 (embedder_unittests:x86_64+0x100a0f842)
    #22 0x100c7b7fa in std::_fl::__function::__alloc_func<fml::Thread::Thread(std::_fl::function<void (fml::Thread::ThreadConfig const&)> const&, fml::Thread::ThreadConfig const&)::$_0, std::_fl::allocator<fml::Thread::Thread(std::_fl::function<void (fml::Thread::ThreadConfig const&)> const&, fml::Thread::ThreadConfig const&)::$_0>, void ()>::operator()[abi:v15000]()+0x2a (embedder_unittests:x86_64+0x100a0f7fa)
    #23 0x100c77ad6 in std::_fl::__function::__func<fml::Thread::Thread(std::_fl::function<void (fml::Thread::ThreadConfig const&)> const&, fml::Thread::ThreadConfig const&)::$_0, std::_fl::allocator<fml::Thread::Thread(std::_fl::function<void (fml::Thread::ThreadConfig const&)> const&, fml::Thread::ThreadConfig const&)::$_0>, void ()>::operator()()+0x26 (embedder_unittests:x86_64+0x100a0bad6)
    #24 0x10066a525 in std::_fl::__function::__value_func<void ()>::operator()[abi:v15000]() const+0x105 (embedder_unittests:x86_64+0x1003fe525)
    #25 0x10066a3f2 in std::_fl::function<void ()>::operator()() const+0x22 (embedder_unittests:x86_64+0x1003fe3f2)
    #26 0x100c75388 in fml::ThreadHandle::ThreadHandle(std::_fl::function<void ()>&&)::$_0::operator()(void*) const+0xe8 (embedder_unittests:x86_64+0x100a09388)
    #27 0x100c75227 in fml::ThreadHandle::ThreadHandle(std::_fl::function<void ()>&&)::$_0::__invoke(void*)+0xc7 (embedder_unittests:x86_64+0x100a09227)
    #28 0x1324b3e76 in asan_thread_start(void*)+0x46 (libclang_rt.asan_osx_dynamic.dylib:x86_64+0x52e76)
    #29 0x7ff817a5c18a in _pthread_start+0x62 (libsystem_pthread.dylib:x86_64+0x618a)
    #30 0x7ff817a57ae2 in thread_start+0xe (libsystem_pthread.dylib:x86_64+0x1ae2)

Address 0x00031833b530 is located in stack of thread T0 at offset 144 in frame
    #0 0x1002d051f in flutter::testing::EmbedderTest_EmbedderThreadHostUseCustomThreadConfig_Test::TestBody()+0xf (embedder_unittests:x86_64+0x10006451f)

  This frame has 12 object(s):
    [32, 40) 'thread_host' (line 3445)
    [64, 112) 'ref.tmp' (line 3446)
    [144, 148) 'ui_policy' (line 3449) <== Memory access at offset 144 is inside this variable
    [160, 168) 'ui_param' (line 3450)
    [192, 200) 'ref.tmp2' (line 3452)
    [224, 272) 'ref.tmp5' (line 3452)
    [304, 320) 'agg.tmp'
    [336, 340) 'io_policy' (line 3458)
    [352, 360) 'io_param' (line 3459)
    [384, 392) 'ref.tmp6' (line 3460)
    [416, 464) 'ref.tmp10' (line 3460)
    [496, 512) 'agg.tmp11'
HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork
      (longjmp and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: stack-use-after-scope (libclang_rt.asan_osx_dynamic.dylib:x86_64+0x2c542) in pthread_getschedparam+0x3d2
Shadow bytes around the buggy address:
  0x00031833b280: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x00031833b300: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x00031833b380: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x00031833b400: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x00031833b480: 00 00 00 00 f1 f1 f1 f1 00 f2 f2 f2 f8 f8 f8 f8
=>0x00031833b500: f8 f8 f2 f2 f2 f2[f8]f2 f8 f2 f2 f2 f8 f2 f2 f2
  0x00031833b580: f8 f8 f8 f8 f8 f8 f2 f2 f2 f2 00 00 f2 f2 f8 f2
  0x00031833b600: f8 f2 f2 f2 f8 f2 f2 f2 f8 f8 f8 f8 f8 f8 f2 f2
  0x00031833b680: f2 f2 00 00 f3 f3 f3 f3 00 00 00 00 00 00 00 00
  0x00031833b700: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x00031833b780: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
Thread T2 created by T0 here:
    #0 0x1324ae92d in pthread_create+0x5d (libclang_rt.asan_osx_dynamic.dylib:x86_64+0x4d92d)
    #1 0x100c73901 in fml::ThreadHandle::ThreadHandle(std::_fl::function<void ()>&&)+0x401 (embedder_unittests:x86_64+0x100a07901)
    #2 0x100c73cca in fml::ThreadHandle::ThreadHandle(std::_fl::function<void ()>&&)+0x2a (embedder_unittests:x86_64+0x100a07cca)
    #3 0x100c748c9 in std::_fl::__unique_if<fml::ThreadHandle>::__unique_single std::_fl::make_unique[abi:v15000]<fml::ThreadHandle, fml::Thread::Thread(std::_fl::function<void (fml::Thread::ThreadConfig const&)> const&, fml::Thread::ThreadConfig const&)::$_0>(fml::Thread::Thread(std::_fl::function<void (fml::Thread::ThreadConfig const&)> const&, fml::Thread::ThreadConfig const&)::$_0&&)+0x149 (embedder_unittests:x86_64+0x100a088c9)
    #4 0x100c74335 in fml::Thread::Thread(std::_fl::function<void (fml::Thread::ThreadConfig const&)> const&, fml::Thread::ThreadConfig const&)+0x255 (embedder_unittests:x86_64+0x100a08335)
    #5 0x100c746b2 in fml::Thread::Thread(std::_fl::function<void (fml::Thread::ThreadConfig const&)> const&, fml::Thread::ThreadConfig const&)+0x32 (embedder_unittests:x86_64+0x100a086b2)
    #6 0x106ee0b1a in std::_fl::__unique_if<fml::Thread>::__unique_single std::_fl::make_unique[abi:v15000]<fml::Thread, std::_fl::function<void (fml::Thread::ThreadConfig const&)> const&, fml::Thread::ThreadConfig&>(std::_fl::function<void (fml::Thread::ThreadConfig const&)> const&, fml::Thread::ThreadConfig&)+0x4a (embedder_unittests:x86_64+0x106c74b1a)
    #7 0x106ee08e8 in flutter::ThreadHost::CreateThread(flutter::ThreadHost::Type, std::_fl::optional<fml::Thread::ThreadConfig>, flutter::ThreadHost::ThreadHostConfig const&) const+0x1b8 (embedder_unittests:x86_64+0x106c748e8)
    #8 0x106ee1466 in flutter::ThreadHost::ThreadHost(flutter::ThreadHost::ThreadHostConfig const&)+0x2f6 (embedder_unittests:x86_64+0x106c75466)
    #9 0x106ee19ca in flutter::ThreadHost::ThreadHost(flutter::ThreadHost::ThreadHostConfig const&)+0x2a (embedder_unittests:x86_64+0x106c759ca)
    #10 0x100b6f730 in flutter::EmbedderThreadHost::CreateEngineManagedThreadHost(std::_fl::function<void (fml::Thread::ThreadConfig const&)> const&)+0x3a0 (embedder_unittests:x86_64+0x100903730)
    #11 0x100b6e51c in flutter::EmbedderThreadHost::CreateEmbedderOrEngineManagedThreadHost(FlutterCustomTaskRunners const*, std::_fl::function<void (fml::Thread::ThreadConfig const&)> const&)+0xcc (embedder_unittests:x86_64+0x10090251c)
    #12 0x1002d0748 in flutter::testing::EmbedderTest_EmbedderThreadHostUseCustomThreadConfig_Test::TestBody()+0x238 (embedder_unittests:x86_64+0x100064748)
    #13 0x1089ce93b in void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*)+0x21b (embedder_unittests:x86_64+0x10876293b)
    #14 0x108955bdf in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*)+0x2cf (embedder_unittests:x86_64+0x1086e9bdf)
    #15 0x108955755 in testing::Test::Run()+0x3a5 (embedder_unittests:x86_64+0x1086e9755)
    #16 0x108957b23 in testing::TestInfo::Run()+0x593 (embedder_unittests:x86_64+0x1086ebb23)
    #17 0x10895a8f2 in testing::TestSuite::Run()+0x6e2 (embedder_unittests:x86_64+0x1086ee8f2)
    #18 0x108977d7a in testing::internal::UnitTestImpl::RunAllTests()+0xb9a (embedder_unittests:x86_64+0x10870bd7a)
    #19 0x1089ee88b in bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*)+0x21b (embedder_unittests:x86_64+0x10878288b)
    #20 0x1089770ac in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*)+0x2cc (embedder_unittests:x86_64+0x10870b0ac)
    #21 0x108976c3b in testing::UnitTest::Run()+0x28b (embedder_unittests:x86_64+0x10870ac3b)
    #22 0x1083e45e2 in RUN_ALL_TESTS()+0x22 (embedder_unittests:x86_64+0x1081785e2)
    #23 0x1083e43c8 in main+0x6e8 (embedder_unittests:x86_64+0x1081783c8)
    #24 0x213ff0365  (<unknown module>)

==14398==ABORTING
[1]    14398 abort      ../out/host_debug_unopt/embedder_unittests 
</pre>
</details>

The changes I made (isolated from a larger change, therefore it doesn't seem reasonable by itself):
```diff
 // shell/common/platform_view.cc, L33

 void PlatformView::DispatchPointerDataPacket(
     std::unique_ptr<PointerDataPacket> packet) {
-  delegate_.OnPlatformViewDispatchPointerDataPacket(
-      pointer_data_packet_converter_.Convert(std::move(packet)));
+  delegate_.OnPlatformViewDispatchPointerDataPacket(std::move(packet));
 }
```

Base engine rev: 3fdd8eb47db219f107e9b345585b84f2820f309b

Environment: Macbook with M1 Max Chip, OS 14.4.1

Compiling with:
```
./engine/src/flutter/tools/gn --goma --unoptimized --asan --xcode-symlinks
./depot_tools/ninja -j200 -C ./engine/src/out/host_debug_unopt
./out/host_debug_unopt/embedder_unittests
```

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-04-05 23:47:06 +00:00
Loïc Sharma
5440d99e97 [Windows] Move EGL surface creation (flutter/engine#51920)
_This is a refactoring with no semantic changes._

The engine can start rendering into a view once it's received the view's initial window metrics. In a multi-view world, the initial window metrics will be sent by `FlutterEngineAddView`, which will be called by `FlutterWindowsEngine::CreateView`.

This change creates the view's EGL surface earlier, in `FlutterWindowsEngine::CreateView`, to prepare for multi-view rendering.

Prepares for https://github.com/flutter/flutter/issues/144810
Part of https://github.com/flutter/flutter/issues/142845

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-04-05 20:57:05 +00:00
auto-submit[bot]
ea0283f762 Reverts "Remove #if SHELL_ENABLE_METAL checks in iOS code (#51636)" (flutter/engine#51941)
Reverts: flutter/engine#51636
Initiated by: jmagman
Reason for reverting: This caused a slew of unexpected Scuba changes b/333039358
Original PR Author: jmagman

Reviewed By: {cbracken}

This change reverts the following previous change:
All physical iOS devices Flutter supports (iOS 12+) can run Metal.  The only time Flutter doesn't use Metal afaik is for iOS simulators running < iOS 13, which is covered by a few `if (@available(iOS METAL_IOS_VERSION_BASELINE, *))` checks.

aef5775087/shell/platform/darwin/ios/rendering_api_selection.h (L37-L41)

Remove hardware checks for physical devices.

Remove `shell_enable_metal` from the gn files and the `#if SHELL_ENABLE_METAL` checks in the iOS embedder.

I limited this PR to just iOS, but I imagine it's safe to remove `shell_enable_metal` everywhere? 
97b286ca62/shell/platform/darwin/macos/BUILD.gn (L18)
97b286ca62/tools/gn (L673-L679)
2024-04-05 18:55:44 +00:00
auto-submit[bot]
ee494ad4dd Reverts "Manual Dart roll to 0ac840ba1 and update frontend server snapshot filename (#51921)" (flutter/engine#51927)
Reverts: flutter/engine#51921
Initiated by: zanderso
Reason for reverting: This Dart roll is blocking the roll of the engine to the framework. Unblocking the rolls depends on addressing https://github.com/flutter/flutter/issues/146164.
Original PR Author: jason-simmons

Reviewed By: {zanderso, jonahwilliams}

This change reverts the following previous change:
The Dart SDK is now only building an AOT snapshot for the frontend server (see https://dart-review.googlesource.com/c/sdk/+/359100)
2024-04-05 02:27:25 +00:00
Jason Simmons
564fc1e2d4 Manual Dart roll to 0ac840ba1 and update frontend server snapshot filename (flutter/engine#51921)
The Dart SDK is now only building an AOT snapshot for the frontend server (see https://dart-review.googlesource.com/c/sdk/+/359100)
2024-04-04 22:14:02 +00:00
Loïc Sharma
b0a3fb598e [Windows] Prepare to add/remove views (flutter/engine#51908)
_This is a refactoring with no semantic changes._

Prepare the Windows embedder to add/remove views. In a multi-view world, the platform thread can remove a view while the raster thread presenting to the same view. A lock will be introduced to ensure this does not happen. This shuffles the code around so that the engine can acquire the lock before the compositor presents to the view.

Prepares for https://github.com/flutter/flutter/issues/138179
Part of https://github.com/flutter/flutter/issues/142845

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-04-04 21:33:05 +00:00
Tong Mu
7553282a55 Multiview backing store (flutter/engine#51722)
With this PR, backing stores are labeled with view IDs. When the engine requests the embedder to create a backing store, the engine will promise that it will only be used for a specific view.

This follows the design doc http://flutter.dev/go/backing-stores-for-multi-view-partial-repaint, so that backing stores can be used as a front surface that retains its content last frame.

The engine will create a render target cache for each view to cache backing stores separately.

### Alternative design

The separate render target cache for each view is not needed to implement the design doc, since all usages described in the design doc avoids the engine cache. Instead, we can make the engine still only manage one render target cache for all views, and backing stores in it are interchangeable across views. We might describe the behavior in this way:
* In general, the view ID is just provided to the creating callback as information. (This is how it is seen when the engine cache is avoided.)
* If the engine cache is used, then the created backing store might not be immediately collected, and might be reused for different views.

But it's really hard to explain the mechanism and the result is really confusing (as can be seen from my attempt). Why is there a view ID but it's not used, and if you enable the engine cache it's not even followed?

That's why I chose the current approach. Feel free to suggest otherwise for this.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-04-04 20:47:30 +00:00
utzcoz
04f240de45 Bump Robolectric to 4.12.1 (flutter/engine#51800)
See https://github.com/robolectric/robolectric/releases/tag/robolectric-4.12 and https://github.com/robolectric/robolectric/releases/tag/robolectric-4.12.1 .

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-04-04 20:07:53 +00:00
Jenn Magder
cb29abbd20 Remove #if SHELL_ENABLE_METAL checks in iOS code (flutter/engine#51636)
All physical iOS devices Flutter supports (iOS 12+) can run Metal.  The only time Flutter doesn't use Metal afaik is for iOS simulators running < iOS 13, which is covered by a few `if (@available(iOS METAL_IOS_VERSION_BASELINE, *))` checks.

aef5775087/shell/platform/darwin/ios/rendering_api_selection.h (L37-L41)

Remove hardware checks for physical devices.

Remove `shell_enable_metal` from the gn files and the `#if SHELL_ENABLE_METAL` checks in the iOS embedder.

I limited this PR to just iOS, but I imagine it's safe to remove `shell_enable_metal` everywhere? 
97b286ca62/shell/platform/darwin/macos/BUILD.gn (L18)
97b286ca62/tools/gn (L673-L679)
2024-04-04 19:22:08 +00:00
Jason Simmons
84b23fcb89 Generate only one "Frame Request Pending" event for each pending call to BeginFrame (flutter/engine#51857)
Fixes https://github.com/flutter/flutter/issues/145853
2024-04-04 14:33:19 +00:00
Chinmay Garde
22be0b9fa4 [Impeller] Enable logging a warning when the user opts out of using Impeller. (flutter/engine#51849)
Part of https://github.com/flutter/flutter/issues/144439

This does two things:

* Logs a warning when the embedder requests a non-Impeller preference when creating a shell.
* Makes the iOS embedder request a warning be logged when Impeller is not used.

I decided to put the warning logs in the shell so that as we get more opinionated about Impeller on other platforms, those platforms can just flip a flag with common log origin.
2024-04-03 19:52:51 +00:00
Jason Simmons
296d677a7c Add an engine switch that controls whether the platform isolate API is available. (flutter/engine#51784)
Platform isolates are currently supported only on Android and iOS.

See https://github.com/flutter/flutter/issues/136314
2024-04-02 22:47:04 +00:00
Tong Mu
bf68661eba Remove the view ID check in macOS/FlutterCompositor (flutter/engine#51852)
This PR removes the view ID check added in https://github.com/flutter/engine/pull/51738, which has been causing a test `FlutterEngineTest.CompositorIgnoresUnknownView`, added in https://github.com/flutter/engine/pull/51436, to fail.

This problem was missed by the CI because the test and the view ID check were added in two PRs recently and they were not using the latest engine to check.

The view ID check is not needed anyway, and is only a temporary check until the multiview support is landed.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-04-02 22:17:36 +00:00
Loïc Sharma
b363028a18 [Embedder API] Add view (flutter/engine#51523)
Adds `FlutterEngineAddView` to the embedder API. This will be used to add a view.

Design doc: https://flutter.dev/go/multi-view-embedder-apis

Part of https://github.com/flutter/flutter/issues/144806
Part of https://github.com/flutter/flutter/issues/142845

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-04-02 21:04:54 +00:00
K Lubick
4ec8483024 Use moved GrBackendTexture factories for Skia's Metal backend (flutter/engine#51828)
In https://skia-review.googlesource.com/c/skia/+/833302, Skia moved the
constructors for Metal versions of GrBackendTexture (and other
functions/methods). This updates uses in Flutter to use the new APIs.

## 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].
- [ ] 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
2024-04-02 11:49:15 -04:00