5392 Commits

Author SHA1 Message Date
Bruno Leroux
195a313245 [macOS,iOS] Expose channel buffers 'resize' and 'overflow' control co… (flutter/engine#44848)
## Description

This PR update the helper function that invokes the control channel 'resize' command (previous implementation relied on a deprecated format). It also adds a similar helper function for the 'overflow' commands exposed by the control channel.

See:

c00c022036/lib/ui/channel_buffers.dart (L302-L309)

## Related Issue

iOS and macOS implementation for https://github.com/flutter/flutter/issues/132386

Similar implementations:
- Android: https://github.com/flutter/engine/pull/44434
- Linux: https://github.com/flutter/engine/pull/44636

## Tests

Adds two tests.
2023-09-19 09:40:18 +00:00
Jonah Williams
88e963e0fd [Android] Add support for setting thread affinity based on core speed. (flutter/engine#45673)
https://github.com/flutter/flutter/issues/134452

This patch parses the speed of all CPU data out of /proc and constructs a table that allows us to request high level CPU affinities: performance, efficiency, and not performance. These affinties are applied where appropriate during Android thread construction.
2023-09-19 03:50:05 +00:00
Chris Bracken
0a532593f1 Revert "[Windows] Update vsync on raster thread (#45310)" (flutter/engine#46000)
This also reverts the ANGLE roll (for which the original fix was landed) to 48e2c605adcd5bcc1622b18f357c7a73ebfb3543.

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

This reverts commit 2bec12f0b4d76d9f60d55d057e16cd2788083ade.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-09-18 22:34:29 +00:00
John McCutchan
c74acc92aa Disable HardwareBuffer backed Platform Views temporarily (flutter/engine#45986)
Necessary to unblock the GPay release
2023-09-18 12:36:16 -07:00
John McCutchan
4081d7d574 Tighten up ImageReaderPlatformViewRenderTarget code (flutter/engine#45889)
- Fix a missing Image close in an error path.
- Ensure we close the Image when the TextureEntry is finalized.
- Fix an inconsistency in the maxImages when running on Android < 33.
- Wrap acquireLatestImage in a try block and return a null image instead
of crashing the application.
2023-09-18 12:34:10 -07:00
LongCatIsLooong
5b716552a7 [iOS] Remove selectionDidChange call in UndoManager (flutter/engine#45657)
Fixes https://github.com/flutter/flutter/issues/133424

The `-[TextInputDelegate selectionDidChange:]` call actually triggers some unwanted keyboard NLP actions that generate a bunch of candidates and automatically accept the first candidate. This causes `-[UITextInput setMarkedText:selection]` to be called with the first candidate and that inserts extraneous characters after the user types certain characters on the iPad software keyboard.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-09-18 17:18:57 +00:00
Jonah Williams
83f48da122 Revert "[Impeller] construct text frames on UI thread." (flutter/engine#45910)
Reverts flutter/engine#45418

Some google3 tests are hitting the CHECK I added in the DlSkCanvasDispatcher::drawTextFrame, which indicates that the SkParagraph code likely thinks impeller is enabled, whereas other code might be running with Skia.

Perhaps this could happen if its software rendering? It should be a fatal error on startup so we can track this down.
2023-09-16 01:22:13 +00:00
Kevin Lubick
7da278b05b Migrate GrMipmapped->skgpu::Mipmapped (flutter/engine#45881)
Skia's Graphite and Ganesh backend coalesced two enums regarding mipmaps
into one and deprecated the public Ganesh version. This migrates Flutter
to use the preferred type.

No functional changes expected. See also
https://skia-review.googlesource.com/c/skia/+/753567

## 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.
- [ ] 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
2023-09-15 11:48:20 -04:00
XuanTung95
f95e3baebc Reduce unnecessary Dart_TimelineGetMicros call (flutter/engine#45637)
Minor changes that reduce unnecessary Dart_TimelineGetMicros calls.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-09-14 22:46:56 +00:00
yaakovschectman
52ce8f488d Handle external window's WM_CLOSE in lifecycle manager (flutter/engine#45840)
Handle the close messages from non-Flutter windows similarly to how we
handle our own, for graceful app exit purposes.

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

## 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
2023-09-14 17:07:14 -04:00
Michael Goderbauer
efc22ee283 Enable private field promotion (flutter/engine#45722)
New feature in upcoming Dart 3.2. See https://github.com/dart-lang/language/issues/2020. Feature is enabled by bumping the min SDK version to 3.2.

Part of https://github.com/flutter/flutter/issues/134476.
2023-09-14 21:02:03 +00:00
yaakovschectman
deaf9cc98c Use start instead of extent for Windows IME cursor position (flutter/engine#45667)
When composing with the IME in a text edit, we should add the `start` of
the composition range to the in-composition `cursor_pos` rather than its
`extent`. When using `extent`, the cursor position would always be
outside of the composition range, resulting in the linked bug. Add a
test to check cursor position.

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

## 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
2023-09-13 16:17:48 -04:00
gaaclarke
0a381989a4 Revert "[Impeller] Patch the compiler to account for subpass inputs and PSO metadata." (flutter/engine#45777)
Reverts flutter/engine#45739
fixes https://github.com/flutter/flutter/issues/134666
2023-09-13 18:46:14 +00:00
Chinmay Garde
6631e24259 [Impeller] Patch the compiler to account for subpass inputs and PSO metadata. (flutter/engine#45739)
Towards https://github.com/flutter/flutter/issues/128911

Drive by fixes https://github.com/flutter/flutter/issues/123795
2023-09-12 23:39:16 +00:00
gaaclarke
9a1606cb17 Added test to assert the vulkan embedder threadsafe vkqueue usage (flutter/engine#45732)
fixes https://github.com/flutter/flutter/issues/133933

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-09-12 21:52:10 +00:00
Chinmay Garde
cf31c43c78 [Impeller] If validations are enabled but not found, still create the VK context. (flutter/engine#45674)
Fixes https://github.com/flutter/flutter/issues/131714
2023-09-12 21:30:04 +00:00
Chris Yang
c2976f7ad8 Reland "Build iOS unittest target in unopt builds" (#44356)"" (#45346)" (flutter/engine#45519)
Reland https://github.com/flutter/engine/pull/44821

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-09-12 19:17:01 +00:00
Chris Yang
911433bc29 [ios] Fix testDeallocated failing locally. (flutter/engine#45663)
Moving the code block to autorelease pool to ensure the FlutterEngine is released in the test.

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

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-09-12 18:43:40 +00:00
gaaclarke
296e9102a0 [Impeller] moved validation layers on by default logic to gni scripts (flutter/engine#45682)
fixes https://github.com/flutter/flutter/issues/134460

Test will happen in the flutter repo as a result of
https://github.com/flutter/flutter/issues/134175

## 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 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
2023-09-12 09:41:55 -07:00
Derek Xu
6a088c7a02 Add trace-to-file switch (flutter/engine#45553) 2023-09-12 11:35:10 -04:00
yaakovschectman
aaea38144b Merge Window into FlutterWindow (flutter/engine#45542)
Merge abstract base class `Window` into concrete derived class
`FlutterWindow` to simplify future development.

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

## 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>
2023-09-11 17:59:47 -04:00
gaaclarke
4c3f956980 Revert "Makes Skia's vkQueueSubmit threadsafe." (flutter/engine#45650)
Reverts flutter/engine#45459

I'm going to revert this. It works fine in tests, but it's not going to work for real usage of the embedder since the user has free access to the vkQueue and thus has no way to ensure that the vkQueue isn't used concurrently.

See: https://github.com/flutter/flutter/issues/133933#issuecomment-1712522964
2023-09-11 16:51:13 +00:00
Kevin Lubick
75a05f03e7 Use safer GrDirectContext APIs (flutter/engine#45644)
In http://review.skia.org/750403 and http://review.skia.org/751523, Skia
modified some `GrDirectContext` APIs to make them less error-prone in
response to https://crbug.com/1475906. This updates Flutter to call
those modified 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].
- [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.
- [ ] 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
2023-09-11 11:28:25 -04:00
gaaclarke
66cdbc5dc9 Makes Skia's vkQueueSubmit threadsafe. (flutter/engine#45459)
fixes https://github.com/flutter/flutter/issues/133933

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-09-09 00:52:53 +00:00
hellohuanlin
4d9074ec8b Reverts part of "fix auto-correction highlight on top left corner (Again)" (flutter/engine#45523)
This reverts part of https://github.com/flutter/engine/pull/44779. Verified this to be the regression for https://github.com/flutter/flutter/issues/133908. 

This pair of `textWill/DidChange` calls was added in Beta 1, in order to fix highlight region missing last character (more details [here](https://docs.google.com/document/d/1sM3HMv-SQin39yX1aPUU7vtGv7Hcef1Quc3QhRXBl6A/edit?resourcekey=0-SFYD8vmOIkXiXCZvB1Wlcw#heading=h.ddlvu2i2epyl)). 

However, that fix doesn't work anymore for Beta 7 - it turns out that in Beta 7, the system doesn't rely on the `selectionRects` to determine the highlight region anymore. Instead, the system relies on `firstRectForRange` API. So we fixed the system highlight in `firstRectForRange` in Beta 7. 

So even after reverting this change, the system highlight still works correctly in Beta 7. I was initially leaning towards keeping these calls even after Beta 7, because without it, the `selectionRects` are still out of sync with iOS text input system. (more details [here](https://docs.google.com/document/d/1sM3HMv-SQin39yX1aPUU7vtGv7Hcef1Quc3QhRXBl6A/edit?resourcekey=0-SFYD8vmOIkXiXCZvB1Wlcw)). 

However, I was able to verify that it is indeed `textWill/DidChange` that introduced the regression for IME inputs (It's unclear why they are related, so need further investigation). 

In summary, after this revert, system highlights are still in the right place, and with the right length. 

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

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

*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-09-07 20:11:07 +00:00
Emircan Uysaler
929a86d3fc [fuchsia] Restructure Flatland vsync loop (flutter/engine#45531)
This CL restructures Flatland vsync loop to fire for each vsync instead
of each OnNextFrameBegin. As shown in the traces attached to the bug,
the current implementation of firing callbacks on each OnNextFrameBegin
causes skips when Flutter has longer draw calls. By scheduling frames in
between, we are increasing the chance of sending one before the latch
point. OnNextFrameBegin is now used to keep track of present credits and
future presentation times as well as when to start frame, replacing the
need for max_frames_in_flight and vsync_offset fields.

Bug: b/296272449
2023-09-07 14:14:46 -04:00
Kevin Lubick
8aeac03253 Explicitly encode SkImages in SkPictures as PNG (flutter/engine#45511)
Skia plans to stop the default behavior of encoding SkImages in
SkPictures using a PNG encoder. To preserve that behavior, clients need
to explicitly set an SkSerialProc to do so.

This was the only location I could find in Flutter which serialized an
skp.

## 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.
- [ ] 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
2023-09-07 13:06:02 -04:00
Zachary Anderson
a1dcb39a45 Revert "Enforce the rule of calling FlutterView.Render" (flutter/engine#45525)
Reverts flutter/engine#45300

Speculative revert for the post-submit framework CI failure in `windows_startup_test`: https://ci.chromium.org/ui/p/flutter/builders/prod/Windows%20windows_startup_test/6227/overview
2023-09-07 01:35:09 +00:00
stuartmorgan
5dc4e70477 Add macOS support for plugin value publishing (flutter/engine#45502)
These directly copy the iOS APIs, to minimize the branching needed in plugins with shared implementation code, and to facilitate the long-term goal of merging the iOS and macOS plugin headers. This does mean replicating the unfortunately non-idiomatic behavior of having `valuePublishedByPlugin:` sometimes return `nil` and sometimes return `NSNull`, instead of distinguishing between `nil` cases (if that's actually even necessary here) via a more specific API. In isolation I would definitely not design the API with this behavior, but consistency with iOS is the more important factor.

(Eventually I think we'll need a sort of "v2" of iOS plugin APIs since there are a number of strange behaviors that we're currently stuck with, but migrating iOS and macOS together to a new set of APIs won't be any harder than doing just iOS, and in the short to medium term consistency will help the ecosystem more that trying to pre-create better APIs as macOS-only.)

Also fixes `FlutterEngineRegistrar` to have a weak pointer to the engine. This should really already have been the case since plugins can retain the registrar, creating a likely cycle; it's now a guaranteed cycle (and failed unit tests designed to find cycles) without that since the engine itself is now keeping references to them.

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

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-09-06 20:44:02 +00:00
Tong Mu
0b39609150 Enforce the rule of calling FlutterView.Render (flutter/engine#45300)
This PR enforces the rules as documented in `FlutterView.Render`, where
calls in illegal situations should be ignored - but have never been
enforced.

```
  /// This function must be called within the scope of the
  /// [PlatformDispatcher.onBeginFrame] or [PlatformDispatcher.onDrawFrame]
  /// callbacks being invoked.
  ///
  /// If this function is called a second time during a single
  /// [PlatformDispatcher.onBeginFrame]/[PlatformDispatcher.onDrawFrame]
  /// callback sequence or called outside the scope of those callbacks, the call
  /// will be ignored.
```

This rule is very important to implementing multi-view without having to
introduce new APIs. However, currently these illegal calls are not
ignored, and historically many tests (especially integration tests) were
unknowingly running based on this fact. @goderbauer did great work by
eliminating these cases in g3, and it's time for us to make sure these
calls are ignored.

Most effort of this PR goes to unit testing the changes. Some part of
`Shell::Create` is extracted into a static function to avoid duplicate
code.

## 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-09-06 12:56:42 -07:00
Jonah Williams
62031173dd [Impeller] construct text frames on UI thread. (flutter/engine#45418)
Conversion of SkTextBlobs to impeller::TextFrame objects is one of the most expensive operations in display list dispatching. While the rest of the engine and framework makes a reasonable attempt to cache the SkTextBlobs generated during paragraph construction, the design of the dl dispatcher means that these the Impeller backend will always reconstruct all text frames on each frame - even if the display list/picture that contained those text frames was unchanged.

Removing this overhead is one of the goals of https://github.com/flutter/engine/pull/45386 , however this patch is also fairly risky and will be difficult to land. As a more incremental solution, we can instead construct the impeller::TextFrame objects when performing paragraph painting and record them in the display list. This both moves the text frame construction to the UI thread and allows the framework/engine to cache unchanged text frames.

This also does not conflict with the dl_aiks_canvas patch directly, and is fine to land before or after it does. (though I'd argue we should land this first).

To compare the current performance levels, I ran the complex_layout_scroll perf test, since this is fairly text filled. On a Pixel 6 pro.   Across several runs this is a fairly consistent ~1ms raster time improvement.

### Skia
```
  "average_frame_build_time_millis": 1.497333333333333,
  "90th_percentile_frame_build_time_millis": 2.038,
  "99th_percentile_frame_build_time_millis": 17.686,
  "worst_frame_build_time_millis": 23.095,
  "missed_frame_build_budget_count": 3,
  "average_frame_rasterizer_time_millis": 5.5078589743589745,
  "stddev_frame_rasterizer_time_millis": 2.226343414420338,
  "90th_percentile_frame_rasterizer_time_millis": 7.481,
  "99th_percentile_frame_rasterizer_time_millis": 19.11,
  "worst_frame_rasterizer_time_millis": 79.799,
  "missed_frame_rasterizer_budget_count": 7,
  "frame_count": 234,
  "frame_rasterizer_count": 234,
  "new_gen_gc_count": 10,
  "old_gen_gc_count": 2,
 ```
 
 ### Impeller (ToT)
 
 ```
   "average_frame_build_time_millis": 1.431575000000001,
  "90th_percentile_frame_build_time_millis": 2.196,
  "99th_percentile_frame_build_time_millis": 14.486,
  "worst_frame_build_time_millis": 23.728,
  "missed_frame_build_budget_count": 2,
  "average_frame_rasterizer_time_millis": 6.536087499999999,
  "stddev_frame_rasterizer_time_millis": 1.9902712500000004,
  "90th_percentile_frame_rasterizer_time_millis": 9.705,
  "99th_percentile_frame_rasterizer_time_millis": 14.727,
  "worst_frame_rasterizer_time_millis": 17.838,
  "missed_frame_rasterizer_budget_count": 1,
  "frame_count": 240,
  "frame_rasterizer_count": 240,
  "new_gen_gc_count": 10,
  "old_gen_gc_count": 2,
  ```
  
  ### Impeller (Patched)
  
  ```
    "average_frame_build_time_millis": 1.4500167364016743,
  "90th_percentile_frame_build_time_millis": 2.478,
  "99th_percentile_frame_build_time_millis": 14.883,
  "worst_frame_build_time_millis": 18.782,
  "missed_frame_build_budget_count": 1,
  "average_frame_rasterizer_time_millis": 5.023033333333336,
  "stddev_frame_rasterizer_time_millis": 1.6445388888888894,
  "90th_percentile_frame_rasterizer_time_millis": 7.814,
  "99th_percentile_frame_rasterizer_time_millis": 13.497,
  "worst_frame_rasterizer_time_millis": 15.008,
  "missed_frame_rasterizer_budget_count": 0,
  "frame_count": 239,
  "frame_rasterizer_count": 240,
  "new_gen_gc_count": 8,
  "old_gen_gc_count": 0,
  ```
2023-09-06 00:50:48 +00:00
Zachary Anderson
b672497bc9 Adds a comment on clang_arm64_apilevel26 toolchain usage (flutter/engine#45467)
Companion comment to the one in https://github.com/flutter/buildroot/pull/761
2023-09-05 22:56:47 +00:00
Chris Yang
59ce383ddb Fix iOS unittests leak in shared.invoke method channel that causes crash (flutter/engine#45416)
Fixes https://github.com/flutter/flutter/issues/133776

"The crash is due to testShareScreenInvoked presents the activityViewController, which prevents the engineViewController to be dealloc'd in the test: https://github.com/flutter/engine/blob/main/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.mm#L161C4-L161C24"

This fix stubbing the presentViewController call, which prevents the viewController being alloc'd, thus preventing the leak. It is probably sufficient for this test.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-09-05 22:08:10 +00:00
Robert Ancell
e0006ade23 Fix building on Pango 1.49.4 (flutter/engine#45098)
This version added the autoptr macros which we no longer need to define.

https://github.com/flutter/flutter/issues/132881
2023-09-05 08:03:28 +12:00
Tong Mu
a443c671d0 Remove deprecated MOCK_METHODx calls (flutter/engine#45307)
The issue that blocks these mocking methods have been resolved.

However, there is [one more mention of this issue in `run_tests.py`](1410d8beaa/testing/run_tests.py (L400)) and I have no idea why it was marked so. It was originally added [here](https://github.com/flutter/engine/pull/19033/files#diff-521d7c59c3f721b259f094c760c2613e16e889b0f24702280924466109e3b0b0R137).

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-09-02 01:42:21 +00:00
gaaclarke
d23968a976 [Impeller] turned on validations for all debug builds (flutter/engine#45350)
fixes https://github.com/flutter/flutter/issues/133794

This adds the following shared libraries to the flutter.jar for debug builds on arm64:
```
lib/arm64-v8a/libVkLayer_khronos_validation.so
lib/arm64-v8a/libc++_shared.so
```

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-09-01 23:29:22 +00:00
Loïc Sharma
2bec12f0b4 [Windows] Update vsync on raster thread (flutter/engine#45310)
## Background

If the Windows system compositor is enabled, the Windows embedder disables the swap interval so that presenting to a surface does not block until the v-blank. If the Windows system compositor is disabled (which is possible on Windows 7), the Windows embedder enables swap interval to prevent screen tearing.

Updating the swap interval requires making the GL surface current, which we currently do on the platform thread. However, the raster thread also needs the GL surface for rendering. Our current version of ANGLE allows making a GL surface current on multiple threads. However, the latest version of ANGLE errors if a GL context is made current on multiple threads. This is causing the ANGLE roll to fail ([example](https://ci.chromium.org/ui/p/flutter/builders/try/Windows%20Engine%20Drone/203788/overview)).

## Solution

There's two fixes:

1. The GL context is released once the swap interval is updated. This allows the platform thread to set the initial swap interval at start up, before the raster thread is started. This fixes the ANGLE roll.
3. When the system compositor changes, the Windows embedder now switches to the raster thread before updating the swap interval. This ensures that the GL surface is only made current on the raster thread once the raster thread has started. I updated unit tests to cover this scenario and tested this manually on a Windows 7 machine.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-09-01 22:33:01 +00:00
hellohuanlin
ef55ffaa9b [ios][ios17][text_input]fix text input system highlight in iOS 17 Beta 7 with firstRectForRange (flutter/engine#45303)
Design doc with more details: https://docs.google.com/document/d/1sM3HMv-SQin39yX1aPUU7vtGv7Hcef1Quc3QhRXBl6A/edit?resourcekey=0-SFYD8vmOIkXiXCZvB1Wlcw#heading=h.tul5o3hopauh

Just to be safe, for now we only change for iOS 17. However, the same logic should apply to older iOS as well. So will update in a separate PR. 

Basically we were using `firstRectForRange` incorrectly. According to [the API doc](https://developer.apple.com/documentation/uikit/uitextinput/1614570-firstrectforrange), `firstRectForRange` should return **the rect for the queried range, or a subrange through the end of line, if the range encompasses multiple lines**.

For LTR language: 

```
0,  1,  2,  3
4,  5,  6,  7
```
Query: `[1, 2, 3, 4]`
Returns the following rect denoted by `[ ]`: 
```
0,  [1,  2,  3]
4,  5,   6,   7
```

Similarly, for RTL language (Arabic): 

```
 3,   2,   1,   0
 7,    6,   5,   4
```

Query: `[1, 2, 3, 4]`
Returns the following rect denoted by `[ ]`: 
```
[3,  2,  1],  0
 7,   6,  5,   4
```

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

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

*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-09-01 19:03:48 +00:00
Matan Lurey
a330c4ff97 Update (flipping the default from false -> true) and deprecate Paint.enableDithering. (flutter/engine#44705)
Update: Blocked on https://github.com/flutter/engine/pull/44912 landing,
and merging into google3.

---

Partial work towards https://github.com/flutter/flutter/issues/112498.

_**tl;dr**: In Impeller's backend we intend to _always_ dither
gradients, and never allow any changes long-term (i.e., write your own
shader if you want different behavior) with the assumption that dithered
gradients look better most of the time, and don't typically hurt
elsewhere._

Note that, at the time of this writing, I couldn't find a single case of
this being set explicitly to `true` inside Google, and there are between
[100 and 200 publicly accessible on
GitHub](https://github.com/search?q=%22Paint.enableDithering%22+language%3ADart&type=code&l=Dart),
of which virtually all are setting it explicitly to `true`.

There are some (valid) concerns this would cause a lot of golden-file
image diffs, so I'm going to seek explicit approval from the Google
testing team as well as someone from the framework team before landing
this commit.
2023-09-01 10:19:59 -07:00
Chris Yang
b3fc48b91b Reland "ios: remove shared_application and support app extension build #44732" (flutter/engine#45351)
Relands https://github.com/flutter/engine/pull/44732 with fix. 

The original PR returns nil when the assets is not reachable, in some cases, the assets are not loaded yet but will be loaded later, so we should return the asset URL regardless. 

Also added a fallback to main bundle to match the previous implementation. 

The original PR was failed in internal tests in b/297654739
Now with the fix, all tests passed: cl/561449914

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

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-09-01 16:56:49 +00:00
Brian Osman
19d37a310c Migrate Fuchsia VK calls of GrBackend* (flutter/engine#45380)
Follow-up to https://github.com/flutter/engine/pull/45325

No functional change.
2023-09-01 15:41:43 +00:00
Bruno Leroux
1dc91d901e [Linux] Fix channel buffers control commands error handling (flutter/engine#45056)
## Description

This PR fixes a mistake I made on https://github.com/flutter/engine/pull/44636 where the error handling code wrongly relied on `fl_method_channel_invoke_method_finish` instead of  `fl_binary_messenger_send_on_channel_finish`.
The error handling code was not called when running the tests added in https://github.com/flutter/engine/pull/44636 so this mistake did not pop up.

@robert-ancell I added a test that simulates an error response and I had to rely on `g_idle_add` to make it works. Is this approach ok?

## Related Issue

Linux implementation for https://github.com/flutter/flutter/issues/132386

## Tests

Adds one test.
2023-09-01 07:40:25 +00:00
Zachary Anderson
a5bc143d64 Revert "Reland "Build iOS unittest target in unopt builds" (#44356)"" (flutter/engine#45346)
Reverts flutter/engine#44821

clang-tidy failures
https://ci.chromium.org/ui/p/flutter/builders/prod/Mac%20Production%20Engine%20Drone/137227/overview
2023-08-31 14:05:21 -07:00
Chris Yang
238fda902d Reland "Build iOS unittest target in unopt builds" (#44356)" (flutter/engine#44821)
Relands https://github.com/flutter/engine/pull/44301

The original PR was reverted in https://github.com/flutter/engine/pull/44356

The `assert flutter_dylib_time <= ios_test_lib_time, final_message` check is reverted in 0d8aebd040, so we are safe to land this again. 

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-08-31 20:05:34 +00:00
Tong Mu
6207fce970 Replace an unnecessary util function with PostSync (flutter/engine#45190)
Fix an unnecessary util function that I created not knowing there's already `PostSync`.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-08-31 19:36:57 +00:00
Chris Bracken
9bf9453e26 [macOS] Link __availability_version_check (flutter/engine#45333)
Links in an implementation of _availability_version_check on macOS.                
This is required due to an upstream compiler builtin (runtime) change              
that marked this function as weakly-linked via `__attribute__((weak import))`   
As such, no linking failure occurs when the function is unavailable at             
link time.                                                                         
                                                                                   
By providing an implementation, the linker picks up our implementation,            
which looks up symbol in question at runtime (via dlsym) on the first              
invocation, caches it for later invocations, then invokes it. This is,             
in fact, precisely what the original clang builtin implementation did.             
                                                                                   
Upstream clang change: https://reviews.llvm.org/D150397                            
                                                                                   
Issue: https://github.com/flutter/flutter/issues/133777 

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-08-31 18:41:00 +00:00
Brian Osman
c11672e29a Migrate VK calls of GrBackend* (flutter/engine#45325)
In https://skia-review.googlesource.com/c/skia/+/742797 Skia refactored
GrBackend* to not require #ifdefs. This changes
callsites in Flutter to use static functions instead of methods that
were conditionally compiled on those classes.

There should be no functional change.
2023-08-31 14:15:17 -04:00
Zachary Anderson
aad0b0f680 Revert dl split (flutter/engine#45326)
Reverting for https://github.com/flutter/flutter/issues/133525
fixes: https://github.com/flutter/engine/pull/45326
2023-08-31 17:46:12 +00:00
Matej Knopp
3cb8e82909 [macOS] Implement unobstructed platform views (flutter/engine#42960)
Fixes https://github.com/flutter/flutter/issues/129073

## Changes to Embedder API

Introduced `FlutterRegion` to represent arbitrary region:
```cpp
typedef struct {
  /// The size of this struct. Must be sizeof(FlutterRegion).
  size_t struct_size;
  /// Number of rectangles in the region.
  size_t rects_count;
  /// The rectangles that make up the region.
  FlutterRect* rects;
} FlutterRegion;
```

Note that this is identical to struct `FlutterDamage` with more generic
naming. Maybe down the line we could deprecate `FlutterDamage` and use
`FlutterRegion` instead.

Introduced `FlutterBackingStorePresentInfo`:
```cpp

typedef struct {
  size_t struct_size;

  /// The area of the backing store that contains Flutter contents. Pixels
  /// outside of this area are transparent and the embedder may choose not
  /// to render them. Coordinates are in physical pixels.
  FlutterRegion* paint_region;
} FlutterBackingStorePresentInfo;
```
In future this struct may also contain more precise hit test region
(when framework supports it) and/or information relevant to partial
repaint (buffer damage, frame damage).

Added a `backing_store_present_info` field to `FlutterLayer`:

```cpp
typedef struct {
  ...
  /// Extra information for the backing store that the embedder may
  /// use during presentation.
  FlutterBackingStorePresentInfo* backing_store_present_info;
} FlutterLayer;
```

## Changes to the macOS embedder

This PR adds support for `FLTEnableSurfaceDebugInfo` flag in main bundle
`Info.plist` that enables visual indicators of overlay layers.

## Example of unobstructed platform views


https://github.com/flutter/flutter/assets/96958/09a75eee-316b-4d53-a8b4-d6bb4e1e52f7

## 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-08-31 08:02:29 +02:00
Dan Field
ffa16ec08f [Impeller] Reland DlAiksCanvas (flutter/engine#45232)
Relands https://github.com/flutter/engine/pull/45131

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

Differences from last time:

- Some minor merge conflict fixes
- Use the RTree to get the bounds instead of recalculating the bounds
- Make the iOS platform view controller implementation use the impeller-aware slices instead of the display list ones. This has been fixed for Android and the desktop embedding, but I missed iOS. The unit tests weren't actually running before I branched for my PR, @zanderso fixed them up separately and this resulted in catching the failures on post submit last time.
2023-08-31 00:29:23 +00:00