5461 Commits

Author SHA1 Message Date
Dan Field
670b5bd8e7 Fix Platform.script for flutter_tester (flutter/engine#46911)
This addresses the problem in https://github.com/flutter/flutter/issues/12847 which changed slightly over time.

Today, `Platform.script` does not give an empty `file` URI, it gives something like `file://path/to/package/main.dart` _regardless of how the file is actually named_.

After this change, it will give the absolute path to the file being run under test.

So before this change, the new test would have a URI like

```
file:///Users/dnfield/src/flutter/engine/src/main.dart
```

And now it has

```
file:///Users/dnfield/src/flutter/engine/src/out/host_debug_unopt_arm64/gen/platform_test.dart.dill
```

This is going to be helpful in generating relative paths from the test file.
2023-10-16 21:55:06 +00:00
Matej Knopp
64af1329c2 [macOS] FlutterMutatorView should clip to bounds (flutter/engine#46463)
*Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.*

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

*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-10-16 21:14:57 +00:00
John McCutchan
9f4cf7153a Allow Image backed platform view rendering target on Android >= 29 again (flutter/engine#46958)
- Refactor the fence waiting code to only wait on Android >= 33.
- Log a warning message once per image rendering target on Android >= 29 && < 33.
- Add a simple unit test of ImageReaderPlatformViewRenderTargets.
2023-10-16 20:08:13 +00:00
gaaclarke
c8aa0844f2 [Impeller] implements a retry mechanism for dart:ui/Image.toByteData. (flutter/engine#46840)
Design doc: [link](https://docs.google.com/document/d/1Uuiw3pdQxNFTA8OQuZ-kuvYg1NB42XgccQCZeqr4oII/edit#heading=h.hn6wreyrz6fm)
fixes: https://github.com/flutter/flutter/issues/135245

One slight deviation from the design doc is that I decided to make ContextMTL respond to changes to the SyncSwitch instead of having it observe the app state directly.  The benefits are:
1) This keeps that functionality in one location
1) It makes writing tests much easier
1) There's no need of conditional compilation between macos and ios
1) There is no need to add an objc class

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-10-16 18:31:13 +00:00
Jason Simmons
9019beb02b Avoid a deadlock in the flutter_tester process when deleting the Impeller Vulkan context during shutdown (flutter/engine#46860)
The Impeller ContextVK contains a ConcurrentMessageLoop whose threads may invoke Dart timeline APIs.  The Dart APIs will create a thread-local object that will be deleted during thread shutdown.  Therefore, these threads should not outlive the engine/Shell and Dart VM.

Previously, RunTester held the ImpellerVulkanContextHolder on the stack, and its reference to the ContextVK would be dropped while exiting the function after the Shell is destructed.

This PR moves the contents of the tester's ImpellerVulkanContextHolder out of the instance on the stack and into a lambda owned by the Shell.

It also reenables the flutter_tester Impeller tests in the run_tests script.
2023-10-16 14:37:18 +00:00
Bruno Leroux
d003a7f2fb Reland - [Android] Add support for text processing actions (flutter/engine#46817)
## Description

This is a reland of https://github.com/flutter/engine/pull/44579 which was reverted in https://github.com/flutter/engine/pull/46788.

This reland adds a check into `onActivityResult` in order to return early if the result is related to an unknown request code (aka the result is related to a request sent by another plugin).
It also adds one test that simulates receiving such an unknown request code.

## Related Issue

Android engine side for https://github.com/flutter/flutter/issues/107603

## Tests

Adds 4 tests.
2023-10-16 05:43:15 +00:00
Tong Mu
f263e6a49f Revert "Reland: Enforce the rule of calling FlutterView.Render (#45300)" (flutter/engine#46919)
Reverts flutter/engine#45555 due to possible performance regression, b/304898239
2023-10-16 05:37:20 +00:00
Dan Field
96b51058d2 [Impeller] Only allow Impeller in flutter_tester if vulkan is enabled. (flutter/engine#46895)
Follows up on #46389 

That patch was too permissive in cases where a build system enables impeller but not vulkan. This change makes the build succeed in such systems.
2023-10-13 18:57:10 +00:00
Ann Marie Mossman
f885190369 Replace deprecated [UIScreen mainScreen] in FlutterView.mm (flutter/engine#46802)
Addresses: https://github.com/flutter/flutter/issues/130828
2023-10-13 18:23:09 +00:00
Derek Xu
9b06776b0e Use --timeline_recorder=systrace instead of --systrace_timeline (flutter/engine#46884)
`--systrace_timeline` is redundant and makes the `getFlagList` VM
Service RPC not return `timeline_recorder=systrace`
(https://github.com/flutter/devtools/issues/6524#issuecomment-1760090526),
so we would like to deprecate and remove it.
2023-10-13 12:47:51 -04:00
gaaclarke
c053bc814b [Impeller] Started throwing errors if dart:ui/Image.toByteData fails (flutter/engine#46738)
issue: https://github.com/flutter/flutter/issues/135245

This is a first step.  Next we'll implement a retry.

## 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
2023-10-13 09:04:47 -07:00
Kevin Lubick
efc265b5e9 Fix forward declare and some deprecated enums (flutter/engine#46882)
There was a compile error when trying to roll in
http://review.skia.org/764970, and this addresses that.

While I was here, I noticed some uses of the old-named `GrBackend` enum
and updated it to the non-deprecated enum class.

## Pre-launch Checklist

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

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

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[test-exempt]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[C++, Objective-C, Java style guides]:
https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
[testing the engine]:
https://github.com/flutter/flutter/wiki/Testing-the-engine
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
2023-10-13 10:56:27 -04:00
Kevin Lubick
a6761a95ea Update to use GrDirectContexts::MakeVulkan (flutter/engine#46878)
In http://review.skia.org/764516, Skia moved the way to make a Vulkan
context. This updates Flutter to use that new way.

## Pre-launch Checklist

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

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

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[test-exempt]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[C++, Objective-C, Java style guides]:
https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
[testing the engine]:
https://github.com/flutter/flutter/wiki/Testing-the-engine
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
2023-10-13 10:41:25 -04:00
Zachary Anderson
7922a335e8 Don't use objcopy to embed Android icudtl (flutter/engine#46862)
When objcopy is used to embed data into a linkable object file, that
object file will only have default bits set in its header for ABI etc..
If the linker doesn't cooperate by ignoring ABI mismatches on object
files without code, then linking will fail. This PR stops using objcopy
to create an object file that embeds icudtl.dat into the Android
embedder, and instead uses the `bin_to_assembly.py` script that we're
already using for Dart VM snapshot data.

Context in https://github.com/llvm/llvm-project/issues/68915
2023-10-13 07:33:24 -07:00
Emircan Uysaler
218a4e9870 [fuchsia] Add fatal error for Vulkan failure (flutter/engine#46831)
This CL changes vkWaitForFences to cause a FATAL failure as we can't
recover from these errors.

Bug: b/297198565
2023-10-12 17:11:14 -04:00
Dan Field
1e318d57d4 [Impeller] flutter_tester --enable-impeller (flutter/engine#46389)
This patch does the following:

- Updates `flutter_tester` to set up an Impeller rendering context and surface if `--enable-impeller` is set to true, using the Vulkan backend with Swiftshader.
- Updates `run_tests.py` to run all tests except the smoke test (that one really has no rendering impact whatsoever) with and without `--enable-impeller`.
- Updates a few tests to work that were trivial:
  - A couple tests needed updated goldens for very minor rendering differences. Filed https://github.com/flutter/flutter/issues/135684 to track using Skia gold for this instead.
  - Disabled SKP screenshotting if Impeller is enabled, and updated the test checking that to verify an error is thrown if an SKP is requested.
  - The Dart GPU based test now asserts that the gpu context is available if Impeller is enabled, and does not deadlock if run in a single threaded mode.
  - We were missing some trace events around `Canvas::SaveLayer` for Impeller as compared to Skia.
  - A couple other tests had strict checks about exception messages that are slightly different between Skia and Impeller.
- I've filed bugs for other tests that may require a little more work, and skipped them for now. For FragmentProgram on Vulkan I reused an existing bug.

This is part of my attempt to address https://github.com/flutter/flutter/issues/135693, although @chinmaygarde and I had slightly different ideas about how to do this.

The goals here are:

- Run the Dart unit tests we already have with Impeller enabled.
- Enable running more of the framework tests (including gold tests) with Impeller enabled.
- Run all of these tests via public `dart:ui` API rather than mucking around in C++ internals in the engine.
2023-10-11 21:42:24 +00:00
Gray Mackall
0d5c0a660f Revert "[Android] Add support for text processing actions (#44579)" (flutter/engine#46788)
This reverts commit 01345c3ce8c06f09625ea2e1a971187e7ed9c049.

This change is causing integration tests to fail on attempts to roll the latest master version of flutter into the packages repo.

See a sample failure here: https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8767521956894285553/+/u/Run_package_tests/native_integration_tests/stdout

The root cause seems to be that we are getting request codes in `onActivityResult` that we never added to the `requestsByCode` map, so the call to remove returns null (and we then call success getting a NPE).

More info: 
1. There is a [discussion in discord here](https://discord.com/channels/608014603317936148/1161718667566919761/1161721935927980052)
2. And the failure can be reproduced by running `dart run script/tool/bin/flutter_plugin_tools.dart native-test --android --packages file_selector` from the root of the packages repo (with a flutter checkout that contains these changes).

cc @bleroux 

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-10-11 20:49:51 +00:00
John McCutchan
3bd2efe1d3 Rename HardwareBufferExternalTexture* to ImageExternalTexture* (flutter/engine#46786)
Image is the more accurate name and we will eventually have a
HardwareBufferExternalTexture in the future (see
https://developer.android.com/reference/android/graphics/HardwareBufferRenderer
available on Android >= 34).
2023-10-11 12:35:36 -07:00
John McCutchan
da447b9297 Fix 303652511 and add a regression test (flutter/engine#46743)
Fixes internal bug b/303652511 and includes a regression test.

The TL;DR of the bug is that when re-launching a singleton-cached-engine
Flutter activity using FLAG_ACTIVITY_CLEAR_TASK, the teardown of the
previous Flutter activity interleaves with the creation of the new
Flutter activity, resulting in the Flutter engine ending up incorrectly
in the AppLifecycleState.detached state. This then results in the app
being completely unresponsive because Flutter doesn't draw frames in
this state. I don't know if the issue is reproducible in production
under normal user operation, but I'm concerned it very easily could be.
There's also nothing stopping other apps or Android system code from
launching an app using this flag.
2023-10-11 11:29:04 -07:00
Bruno Leroux
01345c3ce8 [Android] Add support for text processing actions (flutter/engine#44579)
## Description

This Android related PR adds a channel buffer and a plugin to interact with Android 'process text' feature. It makes it possible to query text processing actions and to run those actions (for instance 'calling' Google translate).
Text actions that outputs a processed text are supported.

The implementation is based on the great sample provided by @gualse , see https://github.com/flutter/flutter/issues/107603#issuecomment-1646629158. 

In order to return a non empty list of text actions, the implementation will require adding a section to the Android manifest file (see https://github.com/flutter/flutter/issues/107603#issuecomment-1683487087).
Adding this section automatically to new or existing Flutter apps is not part of this PR but will be tackled in a future PR.

## Related Issue

Android engine side for https://github.com/flutter/flutter/issues/107603

## Tests

Adds 3 tests.
2023-10-11 09:33:00 +00:00
Chris Bracken
ee313fa40f Move //third_party/glfw to //flutter/third_party/glfw (flutter/engine#46733)
As part of eliminating the Flutter buildroot (#67373), we are moving all
third-party dependencies from //third_party to //flutter/third_party.

This is the engine-side follow-up to flutter/buildroot#777.

Once all third-party dependencies have been migrated, tooling and config
will be moved and the buildroot will be eliminated altogether.

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

No tests changed because there is no semantic change to this PR. This is
simply relocating a dependency.
2023-10-10 18:21:54 -07:00
John McCutchan
d9469ed169 Fix high FPS screen flicker of Platform Views when using ImageReaderPlatformViewRenderTarget (flutter/engine#46724)
The root bug (b/300627634) was that we were holding onto HardwareBuffers
after the owning Image was closed. This CL refactors the C++ code to
properly hold a reference to the Image until it is safe to dispose of.

This CL also refactors the Impeller GL and Skia GL code paths to share
more code.
2023-10-10 13:36:56 -07:00
Jonah Williams
724d1ae6fc [Impeller] Implement framebuffer fetch support for OpenGLES. (flutter/engine#46585)
https://github.com/flutter/flutter/issues/120223 for OpenGLES. Checks for support of the framebuffer fetch extension: https://registry.khronos.org/OpenGL/extensions/EXT/EXT_shader_framebuffer_fetch.txt . This is supported on a Pixel 6 at least, we should double check the distribution of the extension.

![d3c](https://github.com/flutter/engine/assets/8975114/d2392dc8-e1b1-4084-ac5d-c5744c651a39)
2023-10-10 19:10:11 +00:00
Alexander Aprelev
eb374b3881 [fuchsia] Remove hardcoded fuchsia-imported packages 2.12 sdk version (flutter/engine#46629)
Use sdk version from imported package pubspec.yaml instead.

This unblocks dart->engine roll that currently is failing
https://ci.chromium.org/ui/p/flutter/builders/try/Linux%20Fuchsia/83386/overview.
2023-10-06 14:01:28 -07:00
Kevin Lubick
5d70f10ebb Add Base64::EncodedSize to tidy up allocations (flutter/engine#46624)
As a follow-up to #46543, this adds a dedicated function to compute the
size of the buffer needed to encode data using Base64 instead of calling
the encode function with nullptr.

## Pre-launch Checklist

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

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

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[test-exempt]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[C++, Objective-C, Java style guides]:
https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
[testing the engine]:
https://github.com/flutter/flutter/wiki/Testing-the-engine
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
2023-10-06 16:50:20 -04:00
Kevin Lubick
ec62430ff1 Replace use of Skia's Base64 Encoding/Decoding logic with a copy of the equivalent code (flutter/engine#46543)
Skia would like to remove SkBase64.h from its public API. This ports the
same functionality into Flutter's codebase with tests.

The implementation was copied from
[Skia](387853af19/src/utils/SkBase64.cpp)
then modified to match Flutter's style and have readable tests.

In a follow-up PR, I would like to add a function to pre-flight the
calculation needed to figure out how many
bytes are needed to be allocated, to avoid the clunky double API
call (see the TODOs).

I chose to put the code in `//shell/common` at the suggestion of Flutter
devs, but it needs to be in its own source_set because it is used in a
few other places (for now) and we want to avoid dependency cycles.

## Pre-launch Checklist

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

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

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[test-exempt]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[C++, Objective-C, Java style guides]:
https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
[testing the engine]:
https://github.com/flutter/flutter/wiki/Testing-the-engine
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
2023-10-05 10:21:39 -04:00
Robert Ancell
53d379bfac Use GdkEvent methods to access values, direct access is removed in GTK4. (flutter/engine#46526)
This should have no effect on the current implementation, and will be
one less thing needed when we migrate to GTK4.
2023-10-05 13:46:51 +13:00
Chris Yang
4ccef45a9a [ios] Link PlatformView back to semantics tree (flutter/engine#46471)
The PlatformView does not have a semantics container when added to semantics tree, this PR gives it a semantics container to ensure accessibility traversal works.

This fixes https://github.com/flutter/flutter/issues/135504, which is a regression of 738b1ad94d

Before 738b1ad94d, the traversal works because the PlatformView is added to the accessibilityElements of the FlutterPlatFormViewSemanticsContainer, which implicitly made the FlutterPlatFormViewSemanticsContainer as the PlatformVIew's AccessibilityContainer. 

Now we use the PlatformVIew as the nativeAccessibility of the  FlutterPlatFormViewSemanticsContainer, we need to expilicitly set the container. 

This needs to be cherry-picked since the commit caused the regression was cherry-picked in 738b1ad94d

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-10-04 21:41:53 +00:00
John McCutchan
6a0fe28dac Restrict ImageReader backed Platform Views to Android 33+ (flutter/engine#46478)
This is necessary to be able to access the fence associated with each
frame that is produced. This API is not available below 33.
2023-10-02 19:23:51 -06:00
Bruno Leroux
2475a550db [Linux] Rename 'set_allow_channel_overflow' to 'set_warns_on_channel_… (flutter/engine#46360)
## Description

This PR is a follow-up to https://github.com/flutter/engine/pull/44636 which introduces the `set_allow_channel_overflow` function. It renames this function to `set_warns_on_channel_overflow`.

The previous naming was inspired by the framework side implementation.
c00c022036/lib/ui/channel_buffers.dart (L574)

During the review of the iOS/macOS implementation, https://github.com/flutter/engine/pull/44848#discussion_r1310463864, we agreed that the existing naming is confusing because it implies that overflow will be allowed, but this not the case this function is used to enable/disable error messages when a channel overflows. 

## Related Issue

Follow-up for https://github.com/flutter/flutter/issues/132386.

## Tests

Updates 2 tests.
2023-10-02 05:36:16 +00:00
John McCutchan
af107ceba5 Add an AndroidManifest.xml flag to disable ImageReader backed Platform Views (flutter/engine#46430)
An internal customer is seeing flickering on some high FPS phones.

While we try and reproduce / gain more knowledge of this problem this PR adds a AndroidManifest.xml flag to disable their usage.

The boolean flag is:
```
"io.flutter.embedding.android.DisableImageReaderPlatformViews"
```

Adding the following to your manifest will disable their usage:

```
<meta-data
  android:name="io.flutter.embedding.android.DisableImageReaderPlatformViews"
  android:value="true" />
```
2023-09-30 00:33:33 +00:00
Casey Hillers
f61c3b45a2 Disable enableHardwareBufferRenderingTarget (flutter/engine#46425)
* Causing flickering in web views
* Follow up of cl/569435819 for Google to unblock the rolls
2023-09-29 22:56:07 +00:00
Tong Mu
c7f206212a Multi-view Rasterizer (flutter/engine#45512)
This PR refactors `Rasterizer` so that it's more suitable for multi-view.

Design doc: [flutter.dev/go/multi-view-pipeline-and-rasterizer](http://flutter.dev/go/multi-view-pipeline-and-rasterizer)

With this change, `Rasterizer::DrawToSurfaces` has a structure that can handle drawing to multiple views, although the lack of some functionality still blocks it, mostly related to `ExternalViewEmbedder` and `RasterCache`. 

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-09-29 21:43:55 +00:00
Matej Knopp
d4d0a41bd7 [macOS] Ensure first responder is consistent during and after text input (flutter/engine#46032)
Fixes https://github.com/flutter/flutter/issues/134906
Fixes https://github.com/flutter/flutter/issues/133832

This ensures that there are only two first responder widgets -
`FlutterView` when text input is not active and `TextInputPlugin` when
text input is active. The PR also prevents `FlutterView` stealing first
responder status on mouse click events during text input.

Previously when `TextInputClient` resigned it made `nextResponder` the
first responder, but that was incorrect - `nextResponder` being the
superview (`FlutterViewWrapper`).

## 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
2023-09-29 11:02:42 +02:00
Matej Knopp
fab42e688a Reland: [macOS] performKeyEquivalent cleanup (flutter/engine#46377)
Fixes the issue in original PR where `FlutterViewWrapper` does not pass the key equivalent to subviews thus prevents `TextInputPlugin` from receiving it. Also adds a regression test for this scenario.

Note that key equivalent flow does not respect the regular responder chain. It is passed from root view to down to subviews and if unhandled will be forwarded to menus.

Original message: 

https://github.com/flutter/engine/pull/40706 added a duplicate `NSEvent (KeyEquivalentMarker)` category. This PR removes it. It also removes the call to `markAsKeyEquivalent` from `FlutterViewController`. That call is internal to `FlutterTextInputPlugin` and classes outside should not be calling it.

*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-28 20:41:11 +00:00
Matej Knopp
839d6adae7 [macOS] TextInputPlugin should mark navigation events in IME popover as handled (flutter/engine#46141)
Fixes https://github.com/flutter/flutter/issues/134699

Because of NSTextInputContext API limitations it is not straightforward to determine whether `TextInputPlugin` has handled a text equivalent event or whether it should pass it on. Previously we marked all event  that didn't result in a TextInputClient action as unhandled, but that's does not work for arrow key events while the IME popover is active.

This PR will mark arrow keys event as handled if there is active composition.

*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-28 20:37:47 +00:00
Joel Winarske
40b832a838 [Impeller] Fix OpenGLES EGL_BAD_ACCESS due to context being current on multiple threads. (flutter/engine#46287)
On Linux setting the EGL context from one thread, then setting from another thread will trigger a EGL_BAD_ACCESS error.  The resolution is to clear the context after use on the thread that set it.

https://github.com/flutter/flutter/issues/130619
2023-09-28 20:10:09 +00:00
AJI
86b582a6bc Fix damage calculation when not providing populate_existing_damage for gl embedder (flutter/engine#45611)
# Description

This PR fixes the `gl_populate_existing_damage` in embedder.cc, which currently returns an empty rectangle when a full repaint is needed. This leads to the `frame_damage` being considered empty in rasterizer.cc, causing incorrect partial repaint within Flutter when `gl_populate_existing_damage` is not provided by the embedder.

# Related Issue

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

# Tests

Add a new test. Also fixes damage calculation related tests in EmbedderTest by

* Use a new Dart embedder fixture entry point `render_gradient_retained` which retains the old layer to make sure layer tree diff happens.
* Add `latch.Wait()` after `SetGLPresentCallback` to make sure assertions have been executed.
* Make `existing_damage_rects` static since it should be valid after `populate_existing_damage` returns.
2023-09-28 20:06:51 +00:00
Matej Knopp
c94d335b6b [macOS] FlutterTextInputPlugin should clip to bounds (flutter/engine#46142)
Fixes https://github.com/flutter/flutter/issues/135219
(formerly https://github.com/flutter/flutter/issues/128956)

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-09-28 19:05:55 +00:00
Chris Bracken
87e27ff202 Revert "[macOS] performKeyEquivalent cleanup (#45946)" (flutter/engine#46374)
This broke some keyboard shortcut handling (e.g. cmd-a to select all).

This reverts commit 0deacc6c7023789c4a75155e6798b3cccdc6384a.


## 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
2023-09-28 10:45:11 -07:00
Matej Knopp
0deacc6c70 [macOS] performKeyEquivalent cleanup (flutter/engine#45946)
https://github.com/flutter/engine/pull/40706 added a duplicate `NSEvent (KeyEquivalentMarker)` category. This PR removes it. It also removes the call to `markAsKeyEquivalent` from `FlutterViewController`. That call is internal to `FlutterTextInputPlugin` and classes outside should not be calling it.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-09-28 17:28:47 +00:00
Bruno Leroux
f732952384 [Android] Rename allowChannelBufferOverflow to `setWarnsOnChannelOv… (flutter/engine#46361)
## Description

This PR is a follow-up to https://github.com/flutter/engine/pull/44434 which introduces the `allowChannelBufferOverflow` function. It renames this function to `setWarnsOnChannelOverflow`.

The previous naming was inspired by the framework side implementation.
c00c022036/lib/ui/channel_buffers.dart (L574)

During the review of the iOS/macOS implementation, https://github.com/flutter/engine/pull/44848#discussion_r1310463864, we agreed that the existing naming is confusing because it implies that overflow will be allowed, but this not the case this function is used to enable/disable error messages when a channel overflows. 

## Related Issue

Follow-up for https://github.com/flutter/flutter/issues/132386.

## Tests

Updates 1 test.
2023-09-28 14:08:12 +00:00
Chris Yang
e2bc37bba7 Reland "Reverts "[ios] Fix app extension not able to find assets from… (flutter/engine#46329)
Relands https://github.com/flutter/engine/pull/46283

The original PR had a bug where the relative assets path is reset after not being found in the `bundle`. It should not be reset unless it was not found inside the info.plist in `bundle`

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

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-09-28 00:02:04 +00:00
auto-submit[bot]
8a97e55da3 Reverts "[ios] Fix app extension not able to find assets from unloaded bundle" (flutter/engine#46328)
Reverts flutter/engine#46283
Initiated by: CaseyHillers
This change reverts the following previous change:
Directly use "flutter_assets" as the default path to find the asset path, this works for app extension when the bundle is unloaded.

This PR also adds integration tests for app extensions, which also tests the asset path. 

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

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-09-27 17:57:18 +00:00
Loïc Sharma
f020b2c7c9 [Windows] Improve logic to update swap intervals (flutter/engine#46172)
This relands https://github.com/flutter/engine/pull/45310 to unblock the ANGLE roll with the fix for https://github.com/flutter/flutter/issues/134262.

## Background

### Swap interval

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.

### GL context threading

Our current version of ANGLE allows making a GL context 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)).

The Windows embedder has two GL context threading issues:

1. At startup, the platform thread creates and binds the GL context. This change ensures the GL context is released from the platform thread so that the raster thread can use the GL context for rendering.
2. When the system compositor updates, the GL context is bound to the platform thread to update the swap interval. This change ensures the swap interval update happens on the raster thread.

### Window resizing

Resizing the window recreates the GL surface and resets the swap interval.

The previous fix released the current GL context after updating the swap interval (this ensured the platform thread released the GL context at startup). This broke window resizing as it caused the engine to "lose" its GL context during rendering (see https://github.com/flutter/flutter/issues/134262). This reland releases the GL context only if on the startup case.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-09-27 17:52:17 +00:00
Jason Simmons
bfc3acee24 Declare native wrapper classes in Fuchsia packages as base classes (flutter/engine#46305)
This prohibits other implementations of the class interface that can not act as native wrappers.

See https://github.com/flutter/flutter/issues/123756
2023-09-27 15:44:58 +00:00
Matej Knopp
066459ce65 [macOS] Synchronise modifiers from mouse events for RawKeyboard (flutter/engine#46230)
Fixes https://github.com/flutter/flutter/issues/135349

This has been done for FlutterEmbedderKeyResponder in
https://github.com/flutter/engine/pull/37870, but has not been
implemented for FlutterChannelKeyResponder, which results in RawKeyboard
being out of sync with HardwareKeyboard.

## 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
2023-09-27 17:09:49 +02:00
Kevin Lubick
8656e6b1d4 Update to use GrDirectContexts::MakeGL (flutter/engine#46308)
This was added in https://skia-review.googlesource.com/c/skia/+/760017
and the old versions were deprecated.

## 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].
- [ ] 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-27 10:17:05 -04:00
Chris Yang
043c5a377a [ios] Fix app extension not able to find assets from unloaded bundle (flutter/engine#46283)
Directly use "flutter_assets" as the default path to find the asset path, this works for app extension when the bundle is unloaded.

This PR also adds integration tests for app extensions, which also tests the asset path. 

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

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-09-26 21:47:13 +00:00
Bruno Leroux
ce5194184d [Android] Fix enableSuggestions set to false not honored (flutter/engine#46037)
## Description

This PR fixes an issue where setting `TextField.enableSuggestions` to false was not honored on Android.

Several Android devices (Samsung) and/or IMEs (including GBoard) does not disabled suggestions when `InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS `flag is set. The common solution is to rely on the following flag:  ~~`InputType.TYPE_TEXT_VARIATION_PASSWORD`~~ `InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD`.

Reference:
- https://issuetracker.google.com/issues/36934423#comment4
- https://stackoverflow.com/questions/33148168/inputtype-type-text-flag-no-suggestions-in-samsung/33227237#33227237
- Existing comment on the codebase:
195a313245/shell/platform/android/io/flutter/plugin/editing/TextInputPlugin.java (L270)

## Related Issue

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

## Tests

Adds 1 test.
2023-09-26 20:39:05 +00:00