5111 Commits

Author SHA1 Message Date
Greg Spencer
2af9be9d97 Adding app lifecycle notification for macOS and Linux, add hidden state. (flutter/engine#40542)
## Description

This adds app lifecycle notification for macOS and Linux, and adds a new `hidden` state to the `AppLifecycleState` enum.

To be functional, this needs a corresponding framework change: https://github.com/flutter/flutter/pull/123274

## Related Issues
 - https://github.com/flutter/flutter/issues/30735

## Tests
 - Added tests for state changes.
2023-05-26 23:24:33 +00:00
Chris Bracken
19c02ddcd9 [macOS] Extract more PlatformViewMutator code (flutter/engine#42361)
This extracts an extra method from `[FlutterMutatorView applyFlutterLayer:]` to perform the final PlatformViewContainer and PlatformView re-nesting in the view stack, then apply transforms, and finally apply the outer axis-aligned master clip rect around the whole thing.

This is a refactoring for readability (primarily clearer parameterisation) and applies no semantic changes to the code. This is the last in a series of refactoring applied to this method.

Issue: https://github.com/flutter/flutter/issues/124490

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-05-26 22:14:42 +00:00
Zachary Anderson
5633d0d833 Enable bugprone-unchecked-optional-access, disable in files with warnings (flutter/engine#42359)
First part of https://github.com/flutter/flutter/issues/127701
2023-05-26 21:58:46 +00:00
Renzo Olivares
ea95b85e63 [macOS] Do not bounce editing state back to framework on setEditState (flutter/engine#42091)
Some context for this change https://github.com/flutter/flutter/issues/118642#issuecomment-1550864240 and https://github.com/flutter/flutter/issues/118759#issuecomment-1551906489 . Tldr, the use-case that this bouncing was originally introduced for in #13702 is no longer an issue.

This ack response is also not present on other desktop platforms or iOS.

Fixes [#118759](https://github.com/flutter/flutter/issues/118759) and [#118642](https://github.com/flutter/flutter/issues/118642)
2023-05-26 21:07:02 +00:00
Dan Field
83b6fa4ff7 [Impeller] Avoid encoding metal commands while the GPU is unavailable when decoding images. (flutter/engine#42349)
Fixes https://github.com/flutter/flutter/issues/126878

This disables device private upload on iOS when backgrounded, and disables mipmap generation when backgrounded.

We don't have a good way to test the core problem in this repo because it only reproduces on physical iOS hardware - simulators don't really care if you do this stuff in the background.

I'll write a devicelab test in the framework to capture this. In the mean time it can be reviewed.

We could consider making the IOManager a shared_ptr instead of having an fml::WeakPtr and that'd clean up some of the extra arguments to engine construction - or we could consider vending the sync switch from impeller::Context unconditionally, but it's pretty iOS specific...
2023-05-26 18:46:33 +00:00
Jason Simmons
ff27c6d7a5 [Impeller] Disable the wide gamut settings flag on iOS simulators (flutter/engine#42331)
Wide gamut is not supported on the iOS simulator, and the iOS platform's FlutterView.isWideGamutSupported checked for this.  However, the ImageDecoder decides whether to enable wide gamut based on the engine's settings, so the flag in the settings needs to be modified for the simulator.
2023-05-26 00:31:10 +00:00
Tong Mu
3a4bdfa370 [macOS] Multi-view thread synchronizer (flutter/engine#41915)
This PR adapts `FlutterThreadSynchronizer` to multi-view.

### Problem
The `FlutterThreadSynchronizer` is a macOS engine class to ensure that, if the current window is resized, nothing will not be presented until the layer tree is drawn with the up-to-date size. 

This class is not compatible with multiview. A simple way to realize it is: while the class is owned by `FlutterView`, it blocks the _global_ platform thread and rasterizer thread - there is got to be some problems. Indeed, when I was testing with multiple windows (https://github.com/flutter/engine/pull/40399), the app freezes as soon as I resize a window.

The problem is because Flutter only have one rasterizer thread. When I'm resizing window A, A's synchronizer detects that the size mismatches, so it blocks the rasterizer thread to wait for an updated content with the updated size. However, window B is to be rendered next, and B's size matches and will try to rasterize, and will be blocked due to the blocked rasterizer thread, window A's updated content will never arrive, causing a deadlock.

### Changes
This PR removes the single-view assumption of `FlutterThreadSynchronizer` by making it created by `FlutterEngine` and shared by all `FlutterView`s, and that it prevents rasterization for all views if any view has a mismatched size.

The synchronizer is assigned to the view controller in the `attachToEngine:withId` method (now renamed to `setUpWithEngine:viewId:threadSynchronizer:`.

This PR also adds unit tests for `FlutterThreadSynchronizer`, which didn't have any unit tests at all.
* To achieve this, the `beginResizeForView:` method no longer checks whether  is called on the main thread, but whether it's called on the main queue. These are equivalent for the real main queue, since the documentation promises that the main queue always executes on the main thread. However, this change allows substituting the queue with a custom one for unit tests.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-05-25 22:37:35 +00:00
Tong Mu
3b00b85da8 [Rasterizer] Make resubmit information temporary (flutter/engine#42001)
This PR refactors `Rasterizer` so that the resubmit information is
returned as a temporary struct instead of stored permanently as class
member. This limits the lifetime of these values and reduces class
members.

Additionally, this benefits the multi-view project: if the rasterizer is
going to store multiple surfaces, what variables should be stored in a
map from view IDs? Should all surfaces have a to-be-submitted record?
The answer is "no", because these information is only temporary.

This PR should not need unit tests since it's only a refactor.

## 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 Hixie said 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
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[C++, Objective-C, Java style guides]:
https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
[testing the engine]:
https://github.com/flutter/flutter/wiki/Testing-the-engine
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
2023-05-25 13:11:23 -07:00
Matej Knopp
634c40bf03 [macOS] Fix FlutterViewController retain cycle (flutter/engine#42317)
Fixes https://github.com/flutter/flutter/issues/127572

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-05-25 16:49:05 +00:00
Jonah Williams
be33a58e18 [Impeller] Encode render passes concurrently on iOS. (flutter/engine#42028)
Allows pushing encoding of command buffers to a worker thread, relying on the fact that these buffers are always scheduled in the order that they are enqueued. This follows the guidelines from https://developer.apple.com/documentation/metal/mtlcommandbuffer?language=objc
2023-05-23 19:40:05 +00:00
Zachary Anderson
1a85b3733f Revert "[ios_platform_view] only recycle maskView when the view is applying mutators #41573" (flutter/engine#42231)
Reverts flutter/engine#42115

Failing on the framework tree as in
https://ci.chromium.org/ui/p/flutter/builders/prod/Mac_ios%20platform_views_scroll_perf_ios__timeline_summary/11103/overview
2023-05-22 19:35:47 -07:00
Emircan Uysaler
d84c05920b [fuchsia] Bind ChildViewWatcher on platform thread (flutter/engine#42222)
This CL posts ChildViewWatcher calls on platform thread.

Bug: fxb/125256
2023-05-23 10:00:27 +10:00
Jason Simmons
b4b589148b [Impeller] Return image decoder error messages to the Dart API (flutter/engine#42175)
Fixes https://github.com/flutter/flutter/issues/127061

See https://github.com/flutter/flutter/issues/126768
2023-05-22 20:43:05 +00:00
Chris Yang
b20b25128a Reland "[ios_platform_view] only recycle maskView when the view is applying mutators #41573" (flutter/engine#42115)
The original PR (https://github.com/flutter/engine/pull/41573) was reverted due to https://github.com/flutter/flutter/issues/126951

The issue will be fixed in https://github.com/flutter/engine/pull/42079

This needs to be landed after https://github.com/flutter/engine/pull/42079

fixes: https://github.com/flutter/flutter/issues/125620

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-05-22 20:10:37 +00:00
Tong Mu
4a01af4737 [macOS] Clean up unused methods in FlutterRenderer (flutter/engine#42196)
This PR removes the methods in `FlutterRenderer` that will never be
used.

These methods allows the engine to get a drawable and present a
drawable, but they will never be called on the macOS embedder. This is
because they go through the `FlutterMetalRendererConfig` struct to
`GPUSurfaceMetalSkia`, which is bypassed if the engine has a non-null
external view embedder, which the macOS always provides.

Removing these methods not only cleans up the code (and the confusion),
but also reduces the methods that might need to be migrated for the
multi-view project.

After this change, `FlutterRenderer` is left with very few
functionalities:
* It hosts `device` and `commandQueue`.
* It creates `FlutterRendererConfig`.
* It implements `FlutterTextureRegistry` and
`FlutterTextureRegistrarDelegate`, linking `FlutterTexture` and
`FlutterTextureRegistrar`.

We might want to refactor this class, but that's for the future.

## 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 Hixie said 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
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[C++, Objective-C, Java style guides]:
https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
[testing the engine]:
https://github.com/flutter/flutter/wiki/Testing-the-engine
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
2023-05-21 16:53:57 -07:00
Kevin Lubick
7751d1c5eb Move SkSurface::MakeNull to SkSurfaces::Null (flutter/engine#42158)
In https://skia-review.googlesource.com/c/skia/+/696537 (and earlier in
https://skia-review.googlesource.com/c/skia/+/687639), Skia moved all
SkSurface factories. This changes the last calls of the old static
methods to the methods in the `SkSurfaces` namespace

## 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 Hixie said 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 `///`).
- [x] I signed the [CLA].
- [x] All existing and new tests are passing.

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

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[C++, Objective-C, Java style guides]:
https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
[testing the engine]:
https://github.com/flutter/flutter/wiki/Testing-the-engine
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
2023-05-20 10:11:44 -04:00
Dan Field
f9b687885e [Impeller] avoid creating multiple concurrent message loops for Andorid Vulkan (flutter/engine#42146)
Fixes https://github.com/flutter/flutter/issues/127160

We should avoid creating multiple message loops that each have as many threads as processors on the machine.
2023-05-20 03:41:18 +00:00
chunhtai
dcfd92f566 Overrides accessibilityScrollToVisible (flutter/engine#42047)
fixes https://github.com/flutter/flutter/issues/61624

Observed behavior is that this method is called when an item is swipe-to-focusd in VoiceOver.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-05-19 22:02:05 +00:00
Chris Bracken
206d0974f7 [macOS] Extract PlatformView mutator clip updating (flutter/engine#42164)
Extracts `updatePathClipViewsWithPaths:origin:` which updates the stack of AppKit clip views hosting the platform view.

This change is a cleanup change for readability and makes no semantic changes to how mutator views are applied. Existing unit tests in [FlutterMutatorViewTest.mm](https://github.com/flutter/engine/blob/main/shell/platform/darwin/macos/framework/Source/FlutterMutatorViewTest.mm) are expected to pass without changes.

This is refactoring prior to applying a fix for rotation handling.

Issue: https://github.com/flutter/flutter/issues/124490

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-05-19 19:37:11 +00:00
hellohuanlin
ebe810b435 [floating_cursor_selection]add some comments on the tricky part (flutter/engine#42136)
Many parts of the floating cursor selection feature is pretty tricky. Some took me a while to figure out. So I added some comments to explain a bit for future readers. 

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

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

*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
2023-05-19 16:42:58 +00:00
Bruno Leroux
72e6f7f567 [Android] Fix BasicMessageChannel.resizeChannelBuffer (flutter/engine#41982)
## Description

This PR updates `BasicMessageChannel.resizeChannelBuffer` implementation. Previous implementation builds a wrong `ByteBuffer` and was not tested so it is difficult to know when it stopped working.  

## Related Issue

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

## Tests

Adds 1 test.
2023-05-19 03:46:05 +00:00
chunhtai
750599021c Makes android embedding to send full uri (flutter/engine#41836)
related https://github.com/flutter/flutter/issues/100624

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-05-18 23:38:17 +00:00
Chris Bracken
49afcc0101 [macOS] Refactor PlatformView mutators (flutter/engine#42130)
This refactors `[FlutterMutatorView applyLayer:]` to split out orthogonal behaviour into smaller functions for better readability/maintainability.

Extracts:
* General transform composition to CATransformFromMutations
* Opacity handling
* MasterClip computation
* RoundedRectClip computation

This change is a cleanup change for readability and makes no semantic changes to how mutator views are applied. Existing unit tests in [FlutterMutatorViewTest.mm](https://github.com/flutter/engine/blob/main/shell/platform/darwin/macos/framework/Source/FlutterMutatorViewTest.mm) are expected to pass without changes.

This is refactoring prior to applying a fix for rotation handling.

Issue: https://github.com/flutter/flutter/issues/124490

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-05-18 20:41:05 +00:00
Bruno Leroux
d35d4dc958 [Android] Return keyboard pressed state (flutter/engine#41695)
## Description

This PR updates the Android engine in order to answer to keyboard pressed state queries from the framework (as implemented in https://github.com/flutter/flutter/pull/122885).

## Related Issue

Fixes https://github.com/flutter/flutter/issues/122441
Android engine implementation for https://github.com/flutter/flutter/issues/87391

## Tests

Adds 2 tests.
2023-05-18 20:35:21 +00:00
chunhtai
d21dc12d2f Make iOS embedding to send full uri for deeplinks (flutter/engine#41992)
related https://github.com/flutter/flutter/issues/100624

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-05-18 20:31:17 +00:00
Chris Bracken
871632b29b [macOS] Clean up PlatformView mutator scaling (flutter/engine#42110)
When applying platform view mutators, the mutations array includes a
transform from logical to physical coordinates. Since Cocoa deals only
in logical points, we inject a physical to logical coordinate transform
to counteract this.

Rather than applying this multiple times throughout the
`[FlutterMutatorView applyFlutterLayer]` method we gather a list of
transforms that includes the additional physical to logical scale
transform.

This change is a cleanup change for readability and makes no semantic
changes to how mutator views are applied. Existing unit tests in
[FlutterMutatorViewTest.mm](https://github.com/flutter/engine/blob/main/shell/platform/darwin/macos/framework/Source/FlutterMutatorViewTest.mm)
are expected to pass without changes.

## 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.
- [ ] I added new tests to check the change I am making or feature I am
adding, or Hixie said the PR is test-exempt. See [testing the engine]
for instructions on writing and running engine tests.
- [X] I updated/added relevant documentation (doc comments with `///`).
- [X] I signed the [CLA].
- [X] All existing and new tests are passing.

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

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[C++, Objective-C, Java style guides]:
https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
[testing the engine]:
https://github.com/flutter/flutter/wiki/Testing-the-engine
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
2023-05-17 17:11:51 -07:00
Xilai Zhang
3b3f315061 [g3 roll] Revert "add non-rendering operation culling to DisplayListBuilder" (flutter/engine#42097)
temporary revert of flutter/engine#41463

context: b/283038609
2023-05-17 23:48:04 +00:00
Renzo Olivares
79df264a52 [Android] Do not collapse text selection on shift key up (flutter/engine#42075)
Fixes https://github.com/flutter/flutter/issues/101569

This block of code was originally introduced in https://github.com/flutter/engine/pull/15560 , but removing it does not have any affect on the software text editing controls in GBoard.

Before this change
* shift + arrow right/left selection would collapse after releasing the shift key. 
* shift + mouse click to expand selection would collapse after releasing the shift key.

After this change
* shift key up no longer collapses the selection.
2023-05-17 18:53:03 +00:00
Dan Field
ae728938fc Report displays for macOS (flutter/engine#41998)
https://github.com/flutter/flutter/issues/125939 and https://github.com/flutter/flutter/issues/125938 for macOS

fixes https://github.com/flutter/flutter/issues/121352
2023-05-17 17:17:23 +00:00
gaaclarke
837b7df872 [Impeller] Turned on wide gamut support by default. (#39801) (flutter/engine#41965)
relands flutter/engine#39801

forward fix for internal customers at cl/531288297

## 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.
- [ ] I added new tests to check the change I am making or feature I am
adding, or Hixie said the PR is test-exempt. See [testing the engine]
for instructions on writing and running engine tests.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I signed the [CLA].
- [x] All existing and new tests are passing.

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

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[C++, Objective-C, Java style guides]:
https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
[testing the engine]:
https://github.com/flutter/flutter/wiki/Testing-the-engine
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
2023-05-17 09:11:42 -07:00
Zachary Anderson
df51526b1d Revert "[ios_platform_view] only recycle maskView when the view is applying mutators" (flutter/engine#42080)
Reverts flutter/engine#41573

Crashing on Framework CI
2023-05-16 14:32:18 -07:00
Greg Spencer
f4ac622197 [macOS] Wait for binding to be ready before requesting exits from framework (flutter/engine#41753)
Similar to https://github.com/flutter/engine/pull/41733 and
https://github.com/flutter/engine/pull/41782, this causes the macos
embedding to wait until it hears that the scheduler binding has
registered itself before proceeding to send termination requests to the
framework.

This allows applications that don't use the framework (just use
`dart:ui` directly) to exit automatically when the last window is
closed. Without this change, the last window closes, but the app does
not exit.

Depends on framework PR https://github.com/flutter/flutter/pull/126075
landing first.
2023-05-16 14:29:32 -07:00
Greg Spencer
4eebfb2246 [linux] Wait for binding to be ready before requesting exits from framework (flutter/engine#41782)
## Description

Similar to https://github.com/flutter/engine/pull/41733 and https://github.com/flutter/engine/pull/41753 this causes the linux embedding to wait until it hears that the scheduler binding has registered itself before proceeding to send termination requests to the framework.

This allows applications that don't use the framework (just use `dart:ui` directly) to exit automatically when the last window is closed.  Without this change, the app does not exit when the window is closed.

Depends on framework PR https://github.com/flutter/flutter/pull/126075 landing first.

## Related PRs
 - https://github.com/flutter/engine/pull/41733
 - https://github.com/flutter/engine/pull/41753

## Related Issues
 - https://github.com/flutter/flutter/issues/126033.

## Tests
 - Added a test to make sure that it doesn't send a termination request if the binding hasn't notified that it is ready yet.
2023-05-16 20:34:05 +00:00
Loïc Sharma
ac25948dcc [Windows] Add force redraw to the C++ client wrapper (flutter/engine#42061)
This change adds a C++ client wrapper to Windows's "force redraw" C API. This API can be used to schedule a frame.

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

## Background

The Windows runner has a race at startup:

1. **Platform thread**: creates a hidden window
2. **Platform thread**: launches the Flutter engine
3. **UI/Raster threads**: renders the first frame
4. **Platform thread**: Registers a callback to show the window once the next frame has been rendered.

Steps 3 and 4 happen in parallel and it is possible for step 3 to complete before step 4 starts. In this scenario, the next frame callback is never called and the window is never shown.

The Windows runner will be updated to call the "force redraw" API after it registers the next frame callback. If step 3 hasn't completed yet, the "force redraw" will no-op as a frame is already scheduled. If step 3 has already completed, the "force redraw" will schedule another frame, which will call the next frame callback and show the window.

See this discussion below on why we cannot avoid changing the Windows runner to fix this issue: https://github.com/flutter/engine/pull/42061#issuecomment-1550080722

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-05-16 18:07:15 +00:00
Chris Yang
259217c7aa [ios_platform_view] only recycle maskView when the view is applying mutators (flutter/engine#41573)
A mistake was introduced in https://github.com/flutter/engine/pull/39498  where the maskViews are already recycles each frame. 

Sometimes a PlatformView does not need to be re-composite: (https://github.com/flutter/engine/blob/main/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm#L398-L401), so the mask view for such PlatformView should not be recycled.

This PR changed the `recycleMaskViews` API to allow individual maskviews to be recycled. `ApplyMutator` then only recycle the maskView for that particular PlatformView.

The MaskViewPool is also reworked to be simpler. 

- The pool now contains a single set of mask views, there is no index counter needed.
- When a maskView is needed, try to get it from the pool. 
  - If pool is empty, create a new view.
  - If pool has an available maskview, remove it from the pool.
- When a PlatformView starts to `applyMutator`, it removes current the maskView, insert the maskView to the pool.
- When the above PlatformView needs to a maskView, it grabs one from the pool. 

fixes: https://github.com/flutter/flutter/issues/125620

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-05-16 16:24:05 +00:00
Chris Yang
9640e89255 [ios_platform_view] Only remove platform views from flutter view in reset. (flutter/engine#41709)
Add a class type check during reset when removing the PlatformViews.

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

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-05-16 04:21:04 +00:00
gaaclarke
47b14888c5 [Impeller] switches the wide gamut surface to f16 (flutter/engine#41994)
**requires https://github.com/flutter/flutter/pull/126712 to land
first**

fixes https://github.com/flutter/flutter/issues/126620
integration test at: https://github.com/flutter/flutter/pull/126715

## 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
2023-05-15 10:25:43 -07:00
Kevin Lubick
0946d27add Migrate uses of SkSurface factories (flutter/engine#41978)
In http://review.skia.org/687639, many SkSurface static methods were moved and one was deleted (SkSurface::MakeRasterN32Premul). (SkSurface::MakeNull was omitted accidentally and http://review.skia.org/696537glesource.com/c/skia/+/696537 has not rolled into Flutter yet)

This changes the calls in Flutter to match those moved functions. There should be no functional difference and everything was done pretty mechanically (e.g. find and replace)

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-05-15 16:41:10 +00:00
Casey Hillers
c77155e442 [Impeller] Include AndroidSurfaceVulkanImpeller behind a flag (flutter/engine#42033)
Fixes b/282290672

Google Testing currently does not support vulkan, and constructors like
this need to be behind a flag.

## 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.
- [ ] 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.
2023-05-14 22:29:19 -07:00
Jim Graham
820d1dbbde add non-rendering operation culling to DisplayListBuilder (flutter/engine#41463)
This optimization avoids recording unnecessary render operations that will not affect the output and also eliminates the need for "draw detection" mechanisms like `DlOpSpy` and `CanvasSpy` by remembering if any non-transparent operations were included. The `DlOpSpy` unit tests were updated to check if the results from that object match the new `DisplayList::affects_transparent_surface()` method.

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

In addition, this change will unblock some other Issues:

- https://github.com/flutter/flutter/issues/125318
- https://github.com/flutter/flutter/issues/125403
2023-05-14 02:14:33 +00:00
Bruno Leroux
80c4704ddf [macOS - TextInput] Insert new line only when TextInputAction.newline (flutter/engine#41977)
## Description

This PR updates the macOS text input plugin to avoid adding a new line on a multiline text field when action is not set to `TextInputAction.newline`.

## Related Issue

macOS implementation for https://github.com/flutter/flutter/issues/125879.
(similar to the Linux implementation in https://github.com/flutter/engine/pull/41895).

## Tests

Adds 2 tests.
2023-05-13 06:48:14 +00:00
Dan Field
29c5e7808b [Impeller] [Android] Refactor the Android context/surface implementation to work more like Skia. (flutter/engine#41059)
Noticed this while working on  https://github.com/flutter/flutter/issues/124181

In Impeller right now, Android creates a context for each surface - but in Skia, Android creates one context and shares it across surfaces. For the multiple-engine scenario this matters. This also makes it possible for Android to provide the impeller::Context independently of surface creation.
2023-05-12 07:10:05 +00:00
Bruno Leroux
8a9edf40aa [Linux - TextInput] Do not add new line for send action (flutter/engine#41895)
Respects input action.
2023-05-11 16:32:43 -07:00
Callum Moffat
1b72600567 iPhone floating cursor selection (flutter/engine#36643)
Floating cursor selection hasn't worked as we haven't been returning a real value for `caretRectForPosition:`. If we have the selection rectangles, we can do so. 

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

Requires selection rects to be turned on for iPhone (https://github.com/flutter/flutter/pull/113048)

writing and running engine tests.
2023-05-11 22:19:01 +00:00
Kevin Lubick
0c3dbe50e1 Use moved SkImage procs (flutter/engine#41947)
Use relocated SkImages context typedefs

In http://review.skia.org/661059, we moved many SkImage related methods, including these typedefs. This updates Flutter to use the moved types.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-05-11 20:16:54 +00:00
Greg Spencer
96db8b56f6 [Android] Lifecycle defaults to focused instead of unfocused (flutter/engine#41875)
## Description

In https://github.com/flutter/engine/pull/41702, the default state of the focus bit is "false", assuming that Android will send an `onWindowFocusChanged(true)` when the window is first focused, but there appear to be some cases where that doesn't happen.

This change puts the initial state back to what it used to be: in the absence of focus change events, entering the "onResume" Android state will report the `resumed` state in Flutter. Before this PR, and after https://github.com/flutter/engine/pull/41702, if no focus events were received, it would default to `inactive`.

## Tests
 - Updated tests to match.
2023-05-11 18:08:04 +00:00
Chris Bracken
de7c02c2cb [macos] Disable background colour tests (flutter/engine#41904)
These tests are flaky. Until they've been deflaked, disable the
following two tests:
* FlutterEngineTest.BackgroundIsBlack
* FlutterEngineTest.CanOverrideBackgroundColor

Issue: https://github.com/flutter/flutter/issues/124677
2023-05-10 16:03:58 -07:00
hellohuanlin
80c0f9d47f [backdrop_filter]Avoid relying on internal class details (flutter/engine#41873)
The original code creates an internal `class` which is alarming: 

`NSClassFromString(@"_UIVisualEffectBackdropView")`

This PR removes such usage. 

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

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

*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
2023-05-10 20:31:11 +00:00
yaakovschectman
e0b8175ef4 Only register top level window message listener upon registering service binding (flutter/engine#41733)
Move registering the `WM_CLOSE` message listener in the engine from
initialization to in response to a message sent from `ServiceBinding`
upon its initialization so that we do not intercept window messages when
there is no binding registered.

Addresses https://github.com/flutter/flutter/issues/126033.

## Pre-launch Checklist

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

---------

Co-authored-by: Loïc Sharma <737941+loic-sharma@users.noreply.github.com>
2023-05-10 07:55:39 -04:00
Ian McKellar
4579687380 [fuchsia] Stop calling FIDL from Dart in Flutter integration tests (flutter/engine#41669)
As we move the Dart FIDL bindings we need to stop calling FIDL methods
from Dart in the Flutter repo. This only affects some integration tests.

This moves the FIDL calls into C++ and uses platform messages to make
the functionality available to the Dart tests.
2023-05-09 11:34:21 +10:00