5188 Commits

Author SHA1 Message Date
John McCutchan
845c75ce6c Workaround HardwareRenderer breakage in Android 14 (flutter/engine#52370)
- Destroy ImageReaders on memory trim.
- Unset the VirtualDisplay's surface on memory trim.
- On resume, recreate ImageReaders.
- On resume, do a dumb little dance and then set the VirtualDisplay's surface

Fixes: https://github.com/flutter/flutter/issues/146499
Fixes: https://github.com/flutter/flutter/issues/144219

Internal bug: b/335646931
Android Fix: https://googleplex-android-review.git.corp.google.com/c/platform/frameworks/base/+/27015418

Android 15 will include the fix. Unclear if Android 14 will be patched.
2024-04-30 05:09:05 +00:00
Zachary Anderson
448613ae74 Remove references to goma (flutter/engine#52411)
This removes goma most places except for the arguments to the `gn`
script, which are referenced by recipes. This does not remove goma
capabilities from the GN build entirely. That requires changes in the
buildroot which have to be staged after this change.
2024-04-29 09:40:16 -07:00
Robert Ancell
2ab69c9f42 Use a AT-SPI socket/plug to export the Flutter accessibility state. (flutter/engine#52355)
This will be useful when using GTK4, which doesn't support custom a11y
code in GTK and will require the Flutter code to be exported in a plug.
2024-04-29 09:34:20 +12:00
Jonah Williams
584a0394aa [Impeller] remove image upload from IO thread, limit concurrent worker threads. (flutter/engine#52423)
Fixes https://github.com/flutter/flutter/issues/123058
Fixes https://github.com/flutter/flutter/issues/135443

We're currently using the IO thread to bottleneck image uploads. Instead, just use fewer concurrent worker threads - and cap the limit at something small. For a Pixel device, this should use about 2 threads maximum, instead of  5 (4 worker and 1 IO).
2024-04-28 17:22:15 +00:00
Dustin Green
1bdc2a83c6 [fuchsia] route fuchsia.sysmem2.Allocator (flutter/engine#52187)
Fuchsia's fake-display will be migrating to sysmem2, which requires fuchsia.sysmem2.Allocator to be routed in a few places.

fixes flutter/flutter#146858

- [y] I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
- [y] I read the [Tree Hygiene] wiki page, which explains my responsibilities.
- [na] I read and followed the [Flutter Style Guide] and the [C++, Objective-C, Java style guides].
- [y] I listed at least one issue that this PR fixes in the description above.
- [fixes to existing tests] 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.
- [na] I updated/added relevant documentation (doc comments with `///`).
- [na / googler] I signed the [CLA].
- [y] All existing and new tests are passing.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-04-26 20:05:09 +00:00
Jason Simmons
bef76e554e Fix function type cast warnings for macOS embedder callbacks (flutter/engine#52377)
The latest version of Clang is reporting warnings from the -Wcast-function-type-mismatch check when a function taking a __strong pointer parameter is converted to a void* parameter.
2024-04-26 15:28:11 +00:00
Jonah Williams
45d5af365f [Impeller] Vulkan validation off by default. (flutter/engine#52397)
Fixes https://github.com/flutter/flutter/issues/142659

can be turned on via --enable-vulkan-validation cmd line flag.
2024-04-25 21:04:04 +00:00
Tong Mu
43fed272aa [macOS] Remove extra setViewController and extra import (flutter/engine#52255)
This stub PR removes and extra `setViewController`, which is unnecessary because the view controller's initializer already attaches itself to the engine.

This PR also removes an extra import since `FlutterCompositor` is not used in the engine's definition. As a result, `FlutterEngineTest.mm` needs to import it explicitly.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-04-25 00:26:12 +00:00
Victoria Ashworth
f2c245f93e Remove UIAccessibilityTraitKeyboardKey to fix touch typing (flutter/engine#52333)
`UIAccessibilityTraitKeyboardKey` was added in https://github.com/flutter/engine/pull/4575 so that `TextInputSemanticsObject` supported VoiceOver gestures for text editing features, such as pinch to select text, and up/down fling to move cursor. After experimenting with it, I found that those features were still available even after removing `UIAccessibilityTraitKeyboardKey`. 

Fixes https://github.com/flutter/flutter/issues/94465.

In Touch Typing Mode:

https://github.com/flutter/engine/assets/15619084/ccfe90ff-d3bc-427b-b1aa-9ec1242c0c89

In Standard Typing Mode:

https://github.com/flutter/engine/assets/15619084/c78b1fb0-0816-41fb-9dd5-ed8b8a4cda2d

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-04-24 21:05:13 +00:00
Byoungchan Lee
011c50a4c5 [darwin] Update pixel format handling in FlutterTexture (flutter/engine#52326)
CVPixelBuffers from the application can have arbitrary pixel formats. However, current implementation doesn't support all pixel formats. To address this, add a comment to the FlutterTexture class to clarify which pixel formats are supported. Also, reject unsupported pixel formats so that the application can handle them properly.

Fixes [#147242](https://github.com/flutter/flutter/issues/147242).

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-04-24 18:10:17 +00:00
Jenn Magder
382620c0ef Migrate ios_surface files to ARC (flutter/engine#52139)
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 `ios_surface` classes from MRC to ARC.

Decorate C functions that take or return Objective-C objects or structs containing Objective-C objects with [`cf_audited_transfer`](https://clang.llvm.org/docs/AutomaticReferenceCounting.html#auditing-of-c-retainable-pointer-interfaces).  

Part of https://github.com/flutter/flutter/issues/137801.
2024-04-24 17:54:09 +00:00
Jason Simmons
b84c057bfb Fix some warnings reported by recent versions of clang-tidy (flutter/engine#52349)
* Invalid enum values in the embedder library
* Disable a check that warns about standard usage of GTK macros in the Linux embedder
2024-04-24 17:46:19 +00:00
Chris Bracken
b0c35a4aca [macOS] Disable FlutterEngineTest.BackgroundColor (flutter/engine#52341)
This was re-enabled in https://github.com/flutter/flutter/issues/124677 after fixing leaks in https://github.com/flutter/engine/pull/50832. Since this test involves an NSWindow, there are separate fixes that should be landed to reduce flakes related to lack of NSWindow close calls in the tests. See related AppKit bug report filed at http://www.openradar.me/FB13291861.

Issue: https://github.com/flutter/flutter/issues/145728
Related issue: https://github.com/flutter/flutter/issues/124677

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-04-23 23:21:05 +00:00
hellohuanlin
cabd4fcacd [ios_edit_menu]add native edit menu (flutter/engine#50095)
Support native edit menu on the engine side. 

Design doc: https://docs.google.com/document/d/16-8kn58h_oD902e7vPSh6W20aHRBJKyNOdSe5rbAe_g/edit?resourcekey=0-gVdJ3fbOybV70ZKeHU7fkQ&tab=t.0

*List which issues are fixed by this PR. You must list at least one issue.*

https://github.com/flutter/flutter/issues/103163

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

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-04-22 23:36:18 +00:00
Jenn Magder
80cd050cae Break dependency cycle of FlutterViewController <-> FlutterPlatformView (flutter/engine#52271)
Trying to migrate the iOS embedder MRC to ARC, I'm attempting to break some dependency cycles so it's easier to migrate the "leaf" dependencies to ARC, working my way up.

The cycle is:
**`FlutterViewController`** -> `FlutterView` -> `FlutterPlatformView` ->  (Before this PR)**`FlutterViewController`** 

`FlutterViewController` depends on many other large MRC classes, like FlutterEngine., so I'd like to pull that one out so `FlutterView`, `FlutterPlatformView`, and `FlutterOverlayView` can be migrated to ARC in a smaller PR.

`FlutterPlatformView` only depends on `FlutterViewController` in this one place, casting a `UIViewController` and calling `-forceTouchesCancelled:`.  

0e6143504c/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm (L1201)

Instead, move `-forceTouchesCancelled:` to the existing `FlutterViewResponder` protocol with the other touch events, which `FlutterViewController` already implements.  The cast can then be removed, breaking the cycle.

Clean up all the imports.

Part of https://github.com/flutter/flutter/issues/137801, though this doesn't actually migrate anything to ARC.
2024-04-22 19:03:49 +00:00
Jenn Magder
286b611779 Refactor and migrate FlutterUndoManagerPlugin to ARC (flutter/engine#52234)
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 `FlutterUndoManagerPlugin` from MRC to ARC. 

1. Refactor so the plugin and its tests don't need to understand the details of `FlutterViewController` or `FlutterEngine` (its delegate).  This decouples the plugin, and means it doesn't depend on any MRC classes.
2. Change the delegate so conforming only requires the objects the undo plugin actually needs.

Part of https://github.com/flutter/flutter/issues/137801.
2024-04-22 17:14:35 +00:00
Tong Mu
83414d7856 [macOS] Consolidate view management (flutter/engine#52254)
This PR improves view management logic of the macOS `FlutterEngine`
class.
* View operation assertions are now centralized in
`registerViewController:` and `deregisterViewControllerForIdentifier:`.
* `addViewController` now directly calls `.viewController =` on implicit
views, so that it matches its verbatim description.
* The doc for `addViewController` correctly reflects the fact that it
doesn't support multiple views yet.

Additionally, a useless (for now) member variable is removed.

## 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-19 14:25:49 -07:00
Jim Graham
2f1254623a [Impeller] Use the new DisplayList depth info in the experimental canvas prototype (flutter/engine#52214)
Plumbing the new DL depth data into the experimental direct rendering Impeller canvas prototype.
2024-04-19 18:35:06 +00:00
Tong Mu
1e085fee4c [macOS] Rename viewId to viewIdentifier (flutter/engine#52202)
This PR adds `FlutterViewController` with new API `viewIdentifier` and
renames all occasions that mention "viewId" to "viewIdentifier", to
align with the requirement for the iOS shell.

A new typedef `FlutterViewIdentifier` is also added. ~~The problem is,
we don't have a file to contain this typedef. Currently I put them in a
new file called `common.h`. I'm open to other suggestions.~~ It has been
moved to `FlutterViewController.h`.
* Another alternative is to not use the type def, but use `int64_t`
directly. I'm ok with this choice too, since honestly it's just a 64
int.

Also, macOS's definition for `kFlutterImplicitViewId` has been removed
in favor of the one in `common/constants.h`.

## 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-18 15:05:01 -07:00
Chinmay Garde
3bba94a45f Suppress in-actionable warnings in the iOS profiler. (flutter/engine#52227)
This is a benign log that is not actionable to the end user. The profiler checker for this and tries again anyway.

Fixes https://github.com/flutter/flutter/issues/116193
2024-04-18 19:50:27 +00:00
Robert Ancell
2ba71d60e9 Fix incorrect function name in documentation (flutter/engine#52184) 2024-04-18 09:23:21 +12:00
Matej Knopp
e016cf4d04 [macOS] Handle interleaved movement and gesture events (flutter/engine#52201)
Fixes https://github.com/flutter/flutter/issues/146893

The crash happens, because with magic mouse, it is quite common to
receive `mouseExited:` event while the gesture event is still in
progress. This would reset the gesture state while the gesture event is
still active, leading to assertion when the gesture event ends.

The state machine assumes that when mouse exists that also ends any
gesture events. However that is not the case with magic mouse, which
handles the movement and gesture events separately.

## 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 21:25:18 +02:00
Gray Mackall
49b9556e68 Replace LinkedLists that are used as a queue in android FlutterRenderer with ArrayDeques (flutter/engine#51494)
Inspired by https://github.com/flutter/engine/pull/50767.

[As their documentation notes](https://docs.oracle.com/javase/8/docs/api/java/util/ArrayDeque.html), `ArrayDeque`s are generally faster than LinkedList when used as a queue.

Fixes https://github.com/flutter/flutter/issues/143721

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-04-17 18:43:57 +00:00
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
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
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