4987 Commits

Author SHA1 Message Date
Michael Goderbauer
c3d355cadd Report display sizes in physical pixels on MacOS (flutter/engine#50221)
Fixes https://github.com/flutter/flutter/issues/142629

`Display.size`'s [documentation](https://main-api.flutter.dev/flutter/dart-ui/Display/size.html) says (emphasize mine):

> The **physical** size of this display.

But we have actually been reporting the size in logical pixels - up until now!
2024-02-07 23:19:19 +00:00
Dan Field
9f9ab34867 [Impeller] Log non-default graphics backend usages, use IMPORTANT rather than ERROR (flutter/engine#50448)
Fixes https://github.com/flutter/flutter/issues/142488

- Only logs on iOS if Skia is used instead of Impeller.
- Logs on other platforms if Impeller is used instead of Skia.
- Uses "IMPORTANT" rather than "ERROR" for these logs. This will show up by default since flutter_tools sets ERROR and above as logs to show.
- Adds some tests.
- Makes INFO log print file paths the same as other verbosities.
2024-02-07 21:29:12 +00:00
zijiehe@
9a5734f5a9 Redo "[Fuchsia] Execute most of the testing/fuchsia/test_suites.yaml on debug and release builds" (flutter/engine#50408)
Reverts flutter/engine#50407,
https://github.com/flutter/flutter/issues/142811, redo
https://github.com/flutter/engine/pull/50058.

Comparing to the original change, this redo disabled lto / link time
optimization for x64 release builder. It's a known issue that lto
increased the compilation time from <5 min to over 30 min. (See commit
a1b104c61b.)
Disabling lto is safe on x64 release since fuchsia assembly uses arm64
release build on smart display instead. But I will send a PSA to the
fuchsia team before submitting this change.

Following is the original change description.

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

## 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-02-07 09:50:23 -08:00
auto-submit[bot]
6173975c27 Reverts "Revert "Revert "[Fuchsia] Execute most of the testing/fuchsia/test_suites.yaml on debug and release builds""" (flutter/engine#50407)
Reverts "Reland "[Fuchsia] Execute most of the testing/fuchsia/test_suites.yaml on debug and release builds"""

Reverts flutter/engine#50295

Initiated by: zanderso

Reason for reverting: Timing out on CI

Original PR Author: zijiehe-google-com

Reviewed By: {keyonghan}

This change reverts the following previous change:
Original Description:
Reverts flutter/engine#50291, https://github.com/flutter/flutter/issues/142811

Following is the original change description.

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-02-06 18:49:25 +00:00
zijiehe@
76dce91cf2 Revert "Revert "[Fuchsia] Execute most of the testing/fuchsia/test_suites.yaml on debug and release builds"" (flutter/engine#50295)
Reverts flutter/engine#50291,
https://github.com/flutter/flutter/issues/142811

Following is the original change description.

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

## 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-02-06 09:34:53 -08:00
Jonny Wang
eb4b07ee1d [fuchsia] Bump Fuchsia's API level to 16 (flutter/engine#50358)
Update Fuchsia's API level to 16.

b/322503140


## 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.
2024-02-06 15:34:37 +00:00
Taha Tesser
5f93393312 Fix iOS password autofill prompt dismissal causes layout to resize (flutter/engine#50364)
fixes [Save password prompt dismiss is pushing UI up and down](https://github.com/flutter/flutter/issues/112281)

### Code sample

<details>
<summary>expand to view the code sample</summary> 

```dart
import 'package:flutter/material.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      debugShowCheckedModeBanner: false,
      home: HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  const HomePage({super.key});

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  final TextEditingController controller1 = TextEditingController();
  final TextEditingController controller2 = TextEditingController();

  @override
  void dispose() {
    controller1.dispose();
    controller2.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold( // Replace Scaffold with Material to fix glitch.
      body: Center(
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: <Widget>[
            const Text('Login (Without Scaffold)'),
            AutofillGroup(
              child: Column(
                children: <Widget>[
                  TextField(
                    controller: controller1,
                    autofillHints: const <String>[AutofillHints.username],
                  ),
                  TextField(
                    controller: controller2,
                    autofillHints: const <String>[AutofillHints.password],
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}
```

</details>

### Before

https://github.com/flutter/engine/assets/48603081/dfe36616-e1dd-4c6c-95b0-e4bd89bd3a6a

### After

https://github.com/flutter/engine/assets/48603081/cfb15252-10cd-4521-a1ef-2cace0004588

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-02-05 21:53:03 +00:00
LongCatIsLooong
0c52de1fda visiblePassword uses ASCII keyboard on iOS (flutter/engine#50293)
Fixes https://github.com/flutter/flutter/issues/129113

The documentation states that the `visiblePassword` input type
> Requests a keyboard with ready access to both letters and numbers.

`UIKeyboardTypeASCIICapable` seems to be the closest match.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-02-05 21:34:09 +00:00
Zachary Anderson
c5eac677ca Revert "[Fuchsia] Execute most of the testing/fuchsia/test_suites.yaml on debug and release builds" (flutter/engine#50291)
Reverts flutter/engine#50058 for
https://github.com/flutter/flutter/issues/142811
2024-02-02 11:40:10 -08:00
Bart Cone
1b95fed6c0 [Android] Fix TextInputType.none for devices with physical keyboard (flutter/engine#49980)
## Description

This PR fixes an issue where keystrokes aren't received on Android
devices with physical keyboards (e.g. rugged Zebra devices) when
`keyboardType` is set to `TextInputType.none` on a `TextField`.

The logic in `setTextInputClient` and `canShowTextInput` created an
`inputTarget` with `InputTarget.Type.NO_TARGET` which caused the [input
connection to short
circuit](https://github.com/flutter/engine/blob/main/shell/platform/android/io/flutter/plugin/editing/TextInputPlugin.java#L296)
and not be established.

Bug introduction PR: https://github.com/flutter/engine/pull/26585

## Related Issue

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

## Unit Test Notes

- The existing `showTextInput_textInputTypeNone()` stays green after
update.
- `inputConnection_textInputTypeNone()` updated to `assertNotNull`. I
would make this more specific, but this is my first venture into the
Flutter engine and don't know enough about those connection attributes.

## Demo

Video below with Zebra MC9300 device. This issue can also be reproduced
in a standard android emulator. Simply add a `TextField`, configure
`keyboardType` to be `TextInputType.none` and attempt to enter text
after running and giving focus to textfield.

Before


https://github.com/flutter/engine/assets/1988098/348ca061-b8b9-4483-956e-0732c1238207

After


https://github.com/flutter/engine/assets/1988098/b65c7251-59b4-4c73-9b85-7ac03f47a7e4

## 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-02-01 23:24:39 -08:00
Michael Goderbauer
2134c852b4 Re-add tests deleted on accident (flutter/engine#50223)
This re-adds the tests from https://github.com/flutter/engine/pull/41998/files that were accidentally deleted in https://github.com/flutter/engine/pull/42418/files#diff-2cce780ae0f93b9230cbf44030048dbf9ef4c6e0fdb959a47cae440fac0350faL808, probably because of a bad merge.
2024-02-01 21:51:51 +00:00
John McCutchan
7c04b55f07 Provide a more helpful error message in the case of UnsatisfiedLinkError (flutter/engine#50247)
Related https://github.com/flutter/flutter/issues/83596
2024-02-01 11:04:45 -08:00
Loïc Sharma
5251e0048f Reland "[Windows] Introduce egl::Surface and egl::WindowSurface" (flutter/engine#50148)
# Original pull request description

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

# Reland

https://github.com/flutter/engine/pull/49983 was reverted as it introduced a crash if the render surface fails to be created even though EGL was initialized successfully.

This pull request is split into the following commits:

1. c0b11be79f is the original pull request unchanged
2. 1dc7813845 is the fix: it checks a surface is valid before using it. This also adds several tests to prevent this kind of regression.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-02-01 17:08:15 +00:00
Jonah Williams
0682efb50f [Impeller] size vk swapchain to window size. (flutter/engine#50205)
The size the engine recieves from the `AndroidSurfaceVulkanImpeller::OnScreenSurfaceResize` appears to be correct in the case of window rotation. Use this instead of physical surface properties to set the swapchain image size.

Querying the physical surface properties seems to have some additional non-deterministic delay. This means that querying the properties during a window rotation will frequently return old values.

Fixes https://github.com/flutter/flutter/issues/138780
Fixes https://github.com/flutter/flutter/issues/132708
2024-02-01 03:45:07 +00:00
Robert Ancell
bd70ef1215 Remove string field from FlKeyEvent (flutter/engine#50189)
This field is deprecated in GTK3 [1] and not used in Flutter. It does
not exist in GTK4.

[1] https://docs.gtk.org/gdk3/struct.EventKey.html
2024-02-01 16:17:19 +13:00
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
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