5689 Commits

Author SHA1 Message Date
Jonah Williams
c403a9f417 [Impeller] make GPU tracing off by default. (flutter/engine#50215)
Fixes https://github.com/flutter/flutter/issues/141788
Fixes https://github.com/flutter/flutter/issues/141798

Disable GPU tracing by default.
2024-02-01 00:55:33 +00:00
Jenn Magder
12dc7ef814 Log FlutterJSONMessageCodec decode errors before asserting (flutter/engine#50163)
Logging JSON decode errors on assertion will help track down bugs.
https://github.com/flutter/flutter/issues/100891#issuecomment-1915946340

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-01-31 17:31:00 +00:00
zijiehe@
b2d8969566 [Fuchsia] Execute most of the testing/fuchsia/test_suites.yaml on debug and release builds (flutter/engine#50058)
This change implements a BundledTestRunner to run most of the tests in testing/fuchsia/test_suites.yaml as ExecutableTestRunner.

- Tests with packages out of out/fuchsia_*_x64/ are ignored for now.
- Tests with extra test command line parameters are ignored for now.

The BundledTestRunner can share most of the logic in ExecutableTestRunner and avoid reinventing the wheel.

This change also fixes the build break of fuchsia_tests in fuchsia_release_x64 which allows tests to run on the build as well.

- Tests not built with AOT are filtered out with variant field in test_suites.yaml.

Bug: https://github.com/flutter/flutter/issues/140179

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-01-31 05:39:21 +00:00
Martin Kustermann
891ac4e5bd More correctly name methods regarding event loop that are currently named microtask (flutter/engine#50138)
Flutter implements the UI isolates message via posting to a UI task queue. That task queue has a primary and a secondary queue. The

* primary is used for running tasks resulated to framework (e.g. draw frame)
* secondary is used to run Dart event loop messages (e.g. received data on a socket)

The Dart semantics requires running microtasks before processing the next event loop message.

The way flutter implements by attaching an observer to the secondary queue. Every time a task from the queue is run, all observers are run and one of them is going to run pending microtasks.

In some situations the engine pauses the dart event loop. The terminology used in the code is "microtask" when in reality what it means is "event loop".

=> This PR changes this terminology to reflect what actually happens.
2024-01-31 04:41:28 +00:00
Jonah Williams
1cd141f1a1 [Impeller] Reland: add interface for submitting multiple command buffers at once. (flutter/engine#50180)
Reland of:  https://github.com/flutter/engine/pull/50139

Metal does not seem to like it when we collect 50+ command buffers at once. Adjust the aiks context logic to regularly flush the cmd buffers.
2024-01-30 21:21:48 +00:00
Ivan Inozemtsev
ed5346b40a Support running sound null safe kernels from flutter_jit_runner (flutter/engine#50002)
- use core vm snapshot instead of core-jit, which does not seem to support sound null safety agnostic mode
- remove hardcoded `--no-sound-null-safety` flags from native code and ninja args
- add `sound_null_safety` attribute to `flutter_component` in ninja, which propagates to `dart_kernel`
- migrate one integration test to sound null safety, so that there are integration tests in both modes

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-01-30 21:12:16 +00:00
杨加康
59947fce84 Revert "Close connection on keyboard close (#41500)" (flutter/engine#49366)
Related issue:

https://github.com/flutter/flutter/issues/140508
2024-01-30 19:20:25 +00:00
Jonah Williams
b651a8da81 [Android] Reland: recycle hardware buffer textures. (flutter/engine#50122)
Reland of https://github.com/flutter/engine/pull/50028 , which was reverted because I missed the different API level requirement of getId. getID now returns an optional which is nullopt on API level < 31.

Fixes https://github.com/flutter/flutter/issues/142365
2024-01-30 17:46:20 +00:00
auto-submit[bot]
f3e4437823 Reverts "[Impeller] Add interface for submitting multiple command buffers at once." (flutter/engine#50174)
Reverts flutter/engine#50139
Initiated by: jonahwilliams
This change reverts the following previous change:
Original Description:
The Impeller Vulkan backend benefits from batching submission to the vk graphics queue. Managing this automatically is non-trivial and adds surprising/fragile thread based behavior, see: https://github.com/flutter/engine/pull/49870

Instead, introduce an impeller::CommandQueue object that command buffers must be submitted to in lieu of CommandBuffer->Submit, which has been made private.

TLDR

old
```c++
buffer->Submit();
```

new
```c++
context.GetQueue()->Submit({buffer});
```

The Metal and GLES implementations internally just call the private CommandBuffer->Submit, though there may be future opportunities to simplify here. The Vulkan implementation is where the meat is.

Aiks takes advantage of this by storing all command buffers on the aiks context while rendering a frame, and then performing one submit in aiks_context render. I don't think this will introduce any thread safety problems, as we don't guarantee much about aiks context - nor do we use it in a multithreaded context as far as I know.

Other tasks such as image upload still just directly submit their command buffers via the queue.

Fixes https://github.com/flutter/flutter/issues/141123
2024-01-30 17:13:17 +00:00
Jonah Williams
6b613131d1 [Impeller] Add interface for submitting multiple command buffers at once. (flutter/engine#50139)
The Impeller Vulkan backend benefits from batching submission to the vk graphics queue. Managing this automatically is non-trivial and adds surprising/fragile thread based behavior, see: https://github.com/flutter/engine/pull/49870

Instead, introduce an impeller::CommandQueue object that command buffers must be submitted to in lieu of CommandBuffer->Submit, which has been made private.

TLDR

old
```c++
buffer->Submit();
```

new
```c++
context.GetQueue()->Submit({buffer});
```

The Metal and GLES implementations internally just call the private CommandBuffer->Submit, though there may be future opportunities to simplify here. The Vulkan implementation is where the meat is.

Aiks takes advantage of this by storing all command buffers on the aiks context while rendering a frame, and then performing one submit in aiks_context render. I don't think this will introduce any thread safety problems, as we don't guarantee much about aiks context - nor do we use it in a multithreaded context as far as I know.

Other tasks such as image upload still just directly submit their command buffers via the queue.

Fixes https://github.com/flutter/flutter/issues/141123
2024-01-30 07:48:35 +00:00
Michael Brase
c4608bbfd1 Use structured logging on Fuchsia (flutter/engine#49918)
This change migrates off of the old fuchsia logging apis to use the
structured logging apis. The initial FIDL connection is made during
global initialization (before main()) and the initial minimum log level
is queried from the system. Later on, once the main loop is initialized,
we setup an async task to listen for additional log interest changes
from the system. The advantage of doing this on the main loop is that we
avoid spawning an additional background thread in the process (the
legacy logging apis use the background thread approach).

One added benefit of this change is it reduces the size of the
dart/flutter runner far packages by about 250kb in release mode, because
libsyslog.so and libbackend_fuchsia_globals.so are no longer needed.

flutter/flutter#141924

## Pre-launch Checklist

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

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

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[test-exempt]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[C++, Objective-C, Java style guides]:
https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
[testing the engine]:
https://github.com/flutter/flutter/wiki/Testing-the-engine
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
2024-01-29 22:26:47 -06:00
Michael Brase
5a727d93d3 Fix incorrect FML_VLOG() severity usage (flutter/engine#50118)
The FML_VLOG() macros are designed to use a positive integers, since
they pass -severity to the LogMessage constructor. The negative severity
can also cause some surprising behavior with log filtering. This change
update usages of FML_VLOG(-1) to FML_VLOG(1).

flutter/flutter#141924
2024-01-29 22:23:07 -06:00
Matan Lurey
2c36f428af Revert: "Change how OpenGL textures are flipped in the Android embedder" (flutter/engine#50158)
Reverts #49938.

This broke `packages/packages/camera/camera/example`, and unfortunately
there is no test (in engine, framework, or packages) that would have
caught this. We also suspect (but are not sure) that this is related to
an internal customer reported bug as well (b/322750489).

---

Here is the output _pre_-revert:


![image](https://github.com/flutter/engine/assets/168174/0691feec-67a9-45b1-aa8e-1c692d09430b)

Here is the output _post_-revert:


![image](https://github.com/flutter/engine/assets/168174/016dc79a-1e44-48cf-9ba0-a61397f8e637)
2024-01-29 16:53:05 -08:00
John McCutchan
028c80cee5 Re-Re-land Manually revert TLHC optimizations (flutter/engine#50155)
- ImageReaderSurfaceProducer no longer drops frames when the producer and the consumers are up to two frames out of sync.
- Have the native C++ side of the Android external textures check if a new frame has been pushed and that the texture needs to be updated. This avoids having to schedule a task on the raster thread for each updated texture.
- Notify the engine earlier that a frame is needed when updating a TLHC texture.
- Re-land fix: Don't close the last dequeued from image reader until the dequeued image is no longer used.
2024-01-30 00:51:10 +00:00
Jason Simmons
e6d660a059 Handle construction/destruction of GObject private data containing C++ objects in Linux embedder tests (flutter/engine#50022)
See https://github.com/flutter/flutter/issues/140183
2024-01-29 20:07:04 +00:00
Matan Lurey
43f0f4e1ce Manually revert TLHC optimizations, holding on to width/height changes. (flutter/engine#50144)
Reverts https://github.com/flutter/engine/pull/50065 due to https://github.com/flutter/flutter/issues/142459.

[Discord](https://discord.com/channels/608014603317936148/608020293944082452/1201589744690270338):

> It looks like the failing tests are the resize tests for webview_flutter and google_maps_flutter
I can reproduce the failure locally for: https://github.com/flutter/packages/blob/main/packages/webview_flutter/webview_flutter_android/example/integration_test/webview_flutter_test.dart#L296

I manually merged this to keep https://github.com/flutter/engine/pull/50066.
2024-01-29 19:21:05 +00:00
Loïc Sharma
7918e2046c Revert "[Windows] Introduce egl::Surface and egl::WindowSurface" (flutter/engine#50104)
Reverts flutter/engine#49983
2024-01-27 19:15:04 +00:00
auto-submit[bot]
75c60cf9f1 Reverts "[Android] Cache GPU resources using HardwareBuffer's id as key" (flutter/engine#50114)
Reverts flutter/engine#50028
Initiated by: jonahwilliams
This change reverts the following previous change:
Original Description:
Once a hardware buffer has been imported (a VkImage created for it), we don't ever need to re-create a VkImage, even when the contents change. The same hardware buffer can be identified by ID. Part of https://github.com/flutter/flutter/issues/142153

Otherwise we spend a lot of time re-creating VkImages:

![image](https://github.com/flutter/flutter/assets/8975114/700bc0e2-ab00-417e-89c5-04abe7e1db96)

Draft is here, but is currently leaky: https://github.com/flutter/engine/pull/50028
We only need something like a LRU with the max image size (seems to be 3 for me).  This does log locally that I'm not calling close correctly:

```
E/flutter ( 5580): [ERROR:flutter/shell/platform/android/image_external_texture_vk.cc(51)] Size: 3
W/System  ( 5580): A resource failed to call HardwareBuffer.close. 
W/System  ( 5580): A resource failed to call HardwareBuffer.close. 
W/System  ( 5580): A resource failed to call HardwareBuffer.close. 
W/System  ( 5580): A resource failed to call HardwareBuffer.close. 
W/System  ( 5580): A resource failed to call HardwareBuffer.close. 
W/System  ( 5580): A resource failed to call HardwareBuffer.close. 
W/System  ( 5580): A resource failed to call HardwareBuffer.close. 
W/System  ( 5580): A resource failed to call HardwareBuffer.close. 
W/System  ( 5580): A resource failed to call HardwareBuffer.close. 
W/System  ( 5580): A resource failed to call HardwareBuffer.close. 
W/System  ( 5580): A resource failed to call HardwareBuffer.close. 
W/System  ( 5580): A resource failed to call HardwareBuffer.close. 
W/System  ( 5580): A resource failed to call HardwareBuffer.close. 
W/System  ( 5580): A resource failed to call HardwareBuffer.close. 
W/System  ( 5580): A resource failed to call HardwareBuffer.close. 
W/System  ( 5580): A resource failed to call HardwareBuffer.close. 
W/System  ( 5580): A resource failed to call HardwareBuffer.close. 
W/System  ( 5580): A resource failed to call HardwareBuffer.close. 
W/System  ( 5580): A resource failed to call HardwareBuffer.close. 
W/System  ( 5580): A resource failed to call HardwareBuffer.close. 
W/System  ( 5580): A resource failed to call HardwareBuffer.close. 
W/System  ( 5580): A resource failed to call HardwareBuffer.close. 
```

FYI @johnmccutchan
2024-01-27 04:52:25 +00:00
Jonah Williams
73cf0269b1 [Android] Cache GPU resources using HardwareBuffer's id as key (flutter/engine#50028)
Once a hardware buffer has been imported (a VkImage created for it), we don't ever need to re-create a VkImage, even when the contents change. The same hardware buffer can be identified by ID. Part of https://github.com/flutter/flutter/issues/142153

Otherwise we spend a lot of time re-creating VkImages:

![image](https://github.com/flutter/flutter/assets/8975114/700bc0e2-ab00-417e-89c5-04abe7e1db96)

Draft is here, but is currently leaky: https://github.com/flutter/engine/pull/50028
We only need something like a LRU with the max image size (seems to be 3 for me).  This does log locally that I'm not calling close correctly:

```
E/flutter ( 5580): [ERROR:flutter/shell/platform/android/image_external_texture_vk.cc(51)] Size: 3
W/System  ( 5580): A resource failed to call HardwareBuffer.close. 
W/System  ( 5580): A resource failed to call HardwareBuffer.close. 
W/System  ( 5580): A resource failed to call HardwareBuffer.close. 
W/System  ( 5580): A resource failed to call HardwareBuffer.close. 
W/System  ( 5580): A resource failed to call HardwareBuffer.close. 
W/System  ( 5580): A resource failed to call HardwareBuffer.close. 
W/System  ( 5580): A resource failed to call HardwareBuffer.close. 
W/System  ( 5580): A resource failed to call HardwareBuffer.close. 
W/System  ( 5580): A resource failed to call HardwareBuffer.close. 
W/System  ( 5580): A resource failed to call HardwareBuffer.close. 
W/System  ( 5580): A resource failed to call HardwareBuffer.close. 
W/System  ( 5580): A resource failed to call HardwareBuffer.close. 
W/System  ( 5580): A resource failed to call HardwareBuffer.close. 
W/System  ( 5580): A resource failed to call HardwareBuffer.close. 
W/System  ( 5580): A resource failed to call HardwareBuffer.close. 
W/System  ( 5580): A resource failed to call HardwareBuffer.close. 
W/System  ( 5580): A resource failed to call HardwareBuffer.close. 
W/System  ( 5580): A resource failed to call HardwareBuffer.close. 
W/System  ( 5580): A resource failed to call HardwareBuffer.close. 
W/System  ( 5580): A resource failed to call HardwareBuffer.close. 
W/System  ( 5580): A resource failed to call HardwareBuffer.close. 
W/System  ( 5580): A resource failed to call HardwareBuffer.close. 
```

FYI @johnmccutchan
2024-01-27 01:50:17 +00:00
Dan Field
7d955bfd7c Followups to screenshot patch (flutter/engine#50096)
@gaaclarke
2024-01-26 23:43:05 +00:00
Matan Lurey
e9e5a237f8 Finish landing missing/incorrect header guards across flutter/engine (flutter/engine#50069)
Generated by https://github.com/flutter/engine/pull/48903 (`dart ./tools/header_guard_check/bin/main.dart --fix`).

As discussed with @cbracken and @jmagman, the guards are not technically needed on the Mac/iOS code, but they (a) do not hurt and (b) still provide value if for some reason `#include` is used instead of `#import` (though I suspect we could try to add that to the tool in the future as well).
2024-01-26 19:42:36 +00:00
Dan Field
ce731f3716 Fix Shell::Screenshot for Impeller (flutter/engine#50072)
Fixes https://github.com/flutter/flutter/issues/141571

Shell::Screenshot was impelemnted in a Skia-only way and would crash when invoked. Adds test coverage for the breaking path on iOS that ends up calling `FlutterView drawLayer`.
2024-01-26 17:17:32 +00:00
Matan Lurey
036ccdbd2c Avoid sizing ImageReaderSurfaceProducer smaller than 1x1 (flutter/engine#50066)
Partial fix towards https://github.com/flutter/flutter/issues/142082.

This fixes OpenGLES + SurfaceProducer, but not Vulkan + SurfaceProducer (that requires VK-specific changes).
2024-01-26 00:56:58 +00:00
Jonah Williams
472d16e991 Use clamp sampling mode in external texture. (flutter/engine#50063)
This is a more reasonable default sampling mode.
2024-01-25 16:14:04 -08:00
John McCutchan
b9c9338455 Reland Optimizations for TLHC frame rate and jank (flutter/engine#50065)
- ImageReaderSurfaceProducer no longer drops frames when the producer
and the consumers are up to two frames out of sync.
- Have the native C++ side of the Android external textures check if a
new frame has been pushed and that the texture needs to be updated. This
avoids having to schedule a task on the raster thread for each updated
texture.
- Notify the engine earlier that a frame is needed when updating a TLHC
texture.
- Reland fix: Call SurfaceTextureExternalTexture::ProcessFrame if
dl_image_ is null.
2024-01-25 16:01:54 -08:00
auto-submit[bot]
d4a6b6d842 Reverts "Optimizations for TLHC frame rate and jank" (flutter/engine#50062)
Reverts flutter/engine#50033
Initiated by: zanderso
This change reverts the following previous change:
Original Description:
- ImageReaderSurfaceProducer no longer drops frames when the producer and the consumers are up to two frames out of sync.
- Have the native C++ side of the Android external textures check if a new frame has been pushed and that the texture needs to be updated.  This avoids having to schedule a task on the raster thread for each updated texture.
- Notify the engine earlier that a frame is needed when updating a TLHC texture.
2024-01-25 23:31:18 +00:00
Eitan Liu
745af8297c Fix android new engine in group (flutter/engine#49659)
Fix android `FlutterFragmentActivity.createFlutterFragment()` new engine in group.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-01-25 22:03:57 +00:00
Callum Moffat
b473589fe5 Refactor macOS trackpad gesture tracking (flutter/engine#49424)
The AppKit state machine was not well understood before. Sometimes the engine would leave orphan PanZoomStart after a certain sequences including NSEventPhaseMayBegin

Now track each gesture's specific phase instead of boolean true/false which doesn't really accurately represent the system state.

Fixes https://github.com/flutter/flutter/issues/140730
FIxes https://github.com/flutter/flutter/issues/136622
2024-01-25 21:10:06 +00:00
John McCutchan
c4781018bc Optimizations for TLHC frame rate and jank (flutter/engine#50033)
- ImageReaderSurfaceProducer no longer drops frames when the producer
and the consumers are up to two frames out of sync.
- Have the native C++ side of the Android external textures check if a
new frame has been pushed and that the texture needs to be updated. This
avoids having to schedule a task on the raster thread for each updated
texture.
- Notify the engine earlier that a frame is needed when updating a TLHC
texture.
2024-01-25 12:44:38 -08:00
Jonah Williams
14fe2f8c27 [Impeller] call shutdown method in Android context. (flutter/engine#49992)
The Impeller context requires us to call Shutdown to ensure that all of its spawned worker threads are joined, ensuring that the raster thread retains the last reference. Without this, we may either destroy parts of the context to early, or attempt to join into a worker thread which will fail.
2024-01-25 17:02:34 +00:00
maRci002
e0a9cc7ce0 [web] add support for AppLifecycleState changes (flutter/engine#44720)
closes flutter/flutter#53107

This PR introduces support for `AppLifecycleState` on Web, aligning the web's lifecycle events with those of the mobile platforms. This ensures a more consistent developer experience and better lifecycle management across all platforms.

**PR includes:**

- Page Visibility Handling: Integrated the `visibilitychange` DOM event to determine if the app is in a `resumed` or `paused` state based on the visibility state of the document.
- Page Transition Handling: Used `beforeunload` events to better manage the `detached` state.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-01-25 16:31:12 +00:00
Hasan Mohsin
eb072d8928 [Windows] Set cursor immediately when framework requests update (flutter/engine#49784)
On Windows, when using a `MouseRegion` widget to change the cursor it is not actually updated until the cursor is moved. This is because the Windows embedder only updates the `current_cursor_` field but does not actually set the cursor until the window receives the `WM_SETCURSOR` message when the mouse moves. This change makes it set the cursor immediately.

Fixes flutter/flutter#76622
2024-01-25 00:48:23 +00:00
Loïc Sharma
7aecd394de [Windows] Introduce egl::Surface and egl::WindowSurface (flutter/engine#49983)
This introduces the `egl::Surface` and `egl::WindowSurface` types to abstract a raw `EGLSurface`. This also removes some - but not all - EGL surface logic out from `EGLManager`.

Subsequent pull requests will be necessary to:

1. Move ownership of the `egl::WindowSurface` from `egl::Manager` to `FlutterWindowsView`
2. Refactor external texture's off-screen EGL surface to use `egl::Surface`

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

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-01-25 00:30:53 +00:00
Robert Ancell
7efa9951c2 Add custom FlValue types and support their en/decoding via FlStandardMessageCodec (flutter/engine#49162)
Add Linux support for custom data types in Flutter channels.

Fixes https://github.com/flutter/flutter/issues/140299
2024-01-25 09:29:54 +13:00
Matan Lurey
43599a528a Do not double-increment nextId when using createSurfaceProducer with SurfaceTextures (flutter/engine#50011)
The change is _very_ tiny, but I added some documentation as well.

After this PR, it appears we're "ready" to start using this API once it lands in stable. Hoorah!

Here are local tests using `video_player_android/example`:

## Skia

![Screenshot 2024-01-24 at 10 59 17 AM](https://github.com/flutter/engine/assets/168174/0cc890ee-4c43-47d3-8d3e-4503f5b1a545)

## Impeller

![Screenshot 2024-01-24 at 10 59 46 AM](https://github.com/flutter/engine/assets/168174/bf13a0f0-bcc7-40bf-a521-b61720dab0d9)
2024-01-24 20:15:11 +00:00
Tong Mu
d8b736ec94 [macOS] Fix: Memory sanitizer violated when encoding indirect strings (flutter/engine#49995)
Fixes https://github.com/flutter/flutter/issues/142101

@cbracken However, this unit test requires the unit tests to be compiled
with `--asan` to work. Can we add this flag to CI?

## Pre-launch Checklist

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

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

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[test-exempt]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[C++, Objective-C, Java style guides]:
https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
[testing the engine]:
https://github.com/flutter/flutter/wiki/Testing-the-engine
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
2024-01-24 11:18:07 -08:00
Michael Brase
254f0f9829 Replace Fuchsia logging macros (FX_LOG*) with FML logging (flutter/engine#49970)
This change updates all of the Fuchsia specific logging macros (e.g.
FX_LOG*) to use the logging macros provided by the FML library
(FML_LOG(...)). This will allow us to migrate to Fuchsia structured
logging backend in a future commit.

flutter/flutter#141924
2024-01-24 11:42:15 -06:00
Loïc Sharma
7509954809 [Windows] Introduce egl::Context (flutter/engine#49954)
This introduces a new `egl::Context` type that abstracts a raw `EGLContext`. This also removes the EGL context logic out from `EGLManager`.

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

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-01-23 20:17:02 +00:00
Matan Lurey
549738f77f Change how OpenGL textures are flipped in the Android embedder. (flutter/engine#49938)
h/t @bdero for [writing the actual
code](https://github.com/flutter/flutter/issues/141636#issuecomment-1903677360)
(I just wrote comments).

Manual test[^1] of `cd
packages/packages/video_player/video_player/example && flutter run`:

## Skia

![Screenshot 2024-01-22 at 3 21
20 PM](https://github.com/flutter/engine/assets/168174/f1023251-4b44-47f3-94f8-1d5dced7bcb3)

## Impeller + OpenGL

![Screenshot 2024-01-22 at 9 41
59 AM](https://github.com/flutter/engine/assets/168174/a2bed578-c929-4222-a1f9-010e2dc95b7e)

```xml
<meta-data
      android:name="io.flutter.embedding.android.EnableImpeller"
      android:value="true" />
<meta-data
      android:name="io.flutter.embedding.android.ImpellerBackend"
      android:value="opengles" />
```

Closes https://github.com/flutter/flutter/issues/141636.

[^1]: I can't write a test worth writing at the same time of this PR, so
I've filed https://github.com/flutter/flutter/issues/141973 to do it
after.
2024-01-22 16:52:32 -08:00
Loïc Sharma
e54858b901 [Windows] Rename and move EGL types (flutter/engine#49900)
This is a refactoring with no semantic changes. The following types were renamed:

* `flutter::AngleSurfaceManager` to `flutter::egl::Manager`. In subsequent pull requests, this type will _create_ but not _own_ surfaces. Furthermore, this type will be split up to introduce `flutter::egl::Surface` and `flutter::egl::Context`. The manager will own the contexts and each surface will be owned by its view.
* `flutter::GlProcTable` to `flutter::egl::ProcTable`

This also introduces an `egl` directory to the Windows embedder.

Previous pull request: https://github.com/flutter/engine/pull/49895

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

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-01-22 22:09:25 +00:00
Loïc Sharma
3ed2cd569f [Windows] Fix resize crash (flutter/engine#49935)
https://github.com/flutter/engine/pull/49872 introduced a crash in debug mode if the platform thread starts a window resize in between `OnFrameGenerated` and `OnFramePresented`.

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

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-01-22 19:08:56 +00:00
Loïc Sharma
78728e1649 [Windows] Refactor EGL initialization (flutter/engine#49895)
This is a refactoring with no semantic changes:

1. Fixes incorrect style in `AngleSurfaceManager`
2. Cleans `AngleSurfaceManager`'s initialization logic

Next pull request: https://github.com/flutter/engine/pull/49900

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-01-19 21:32:27 +00:00
Jonah Williams
e7be989feb Reland: Encode directly to command buffer. (flutter/engine#49821)
The original change was reverted as it broke the GPU tracer reset logic. The previous logic assumed that the first started command buffer would also be the first submitted command buffer. With the direct encoding, this is no longer the case - so we shift the logic so that we reset query pools once at startup and then after the queries are finished being recorded.

This might actually be better in general since we should be doing less work in the frame workload.
2024-01-19 19:21:47 +00:00
Bruno Leroux
7001e5cc63 [Android] Fix KeyEmbedderResponder throws a NullPointerException (flutter/engine#49860)
## Description

This PR fixes a `NullPointerException` thrown from `KeyEmbedderResponder` when pressing a key during a hot restart (at this time the framework might not be ready and null reply is sent back).

## Related Issue

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

## Tests

Adds 1 test.
2024-01-19 09:17:06 +00:00
Loïc Sharma
e47107cf38 [Windows] Refactor logic when window resize completes (flutter/engine#49872)
Changes:

1. Moves surface buffer swapping from `FlutterWindowsView` to `CompositorOpenGL`
1. Renames `FlutterWindowsView::SwapBuffers` to `FlutterWindowsView::OnFramePresented`
2. Previously, if a resize was pending and the window was not visible Windows would unblock the platform thread before swapping buffers. This trick aimed to reduce the time the platform thread was blocked as swapping buffers previously waited until the v-blank. This logic was removed as swapping buffers no longer waits until the v-blank.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-01-18 22:11:16 +00:00
Filip Filmar
a53f140211 [fuchsia] Wire through the tzdata-icu capability (flutter/engine#48907)
The `tzdata-icu` capability is a directory containing
ICU time zone resource files. These are requried for
correct computation of local times.

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

## 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.
- [ ] I updated/added relevant documentation (doc comments with `///`).
- [x] I signed the [CLA].
- [x] All existing and new tests are passing.
2024-01-18 13:18:14 -08:00
Bruno Leroux
d925ac1a53 [Android] Reset IME state in TextInputPlugin.clearTextInputClient (flutter/engine#49829)
## Description

This PR calls Android API `InputMethodManager.restartInput` to reset IMEs internal states. Otherwise some IMEs (Gboard for instance) keep reacting based on the previous input configuration until a new configuration is set.

- On Android native, `restartInput` is called in several places, for instance in f219798774/android/widget/TextView.java (L2458).
- On Compose, https://github.com/flutter/flutter/issues/70546#issuecomment-1088345561 pointed out where it is called.
- On Flutter, it is called at some point but mainly when another `TextField` is focused (it is mainly called in `setTextInputEditingState`).

## Related Issue

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

## Tests

Adds 1 test.
2024-01-18 06:38:34 +00:00
Loïc Sharma
31bf4a3285 [Windows] Reduce Visual Studio build errors caused by keyboard unit tests (flutter/engine#49814)
The `EXPECT_CALL_IS_EVENT` macro used features that are not supported by Visual Studio 2022's intellisense, which results in >130 errors when editing in Visual Studio. These issues only affect the editing experience, building still works as expected.

This change reduces false errors in Visual Studio by making `EXPECT_CALL_IS_EVENT` buildable in Visual Studio.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-01-17 23:36:22 +00:00
Loïc Sharma
e38b6f14f6 [Windows] Remove unnecessary statics in keyboard (flutter/engine#49834)
Windows's `KeyboardManager` has several top-level helper functions. These are already wrapped in an anonymous C++ namespace, which is the C++ equivalent of the C `static` keyword.

No tests are updated as this PR is a refactoring with no semantic changes.
  

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-01-17 23:31:33 +00:00
Jenn Magder
a7e652c7d8 Remove iOS 12 availability checks (flutter/engine#49771)
iOS minimum is now 12: https://github.com/flutter/buildroot/pull/808.  Remove `@available` checks for that version.  

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

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-01-16 23:09:58 +00:00