5503 Commits

Author SHA1 Message Date
Chris Yang
5c12a78db9 [ios] making objective-C smart pointers support ARC (flutter/engine#47612)
Moving the implementation from https://codereview.chromium.org/1855483004 into the code base, including:

- scoped_nsobject, scoped_nsprotocol, scoped_block will support both mrc and arc
- Added parent class scoped_typeref for shared code between scoped_block and scoped_nsobject
- moving OwnershipPolicy to its own file

The implementation of the smart pointers are almost identical to https://codereview.chromium.org/1855483004 besides some syntax preference differences between chromium and flutter.

This PR also migrated [VsyncWaiterIosTest.mm](https://github.com/flutter/engine/pull/47612/files#diff-c98ce1a2aca65c29bbc444523b66921a53ecce5ff39a420b4eda7dbfe8ca1cc7) to ARC with scoped_nsobject

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

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-11-07 19:25:45 +00:00
Zachary Anderson
e24e3b5746 Don't use Skia BUILD.gn files (flutter/engine#47677)
The new `BUILD.gn` files in the Engine tree can't go under
`build/secondary` because Skia still has its own, and they'd be selected
first. So, this PR puts the new `BUILD.gn` files under `flutter/skia`.
2023-11-07 11:12:29 -08:00
Jia Hao
847c0f704b Fix ImmutableEnum lint (flutter/engine#47739)
This was introduced in https://github.com/flutter/engine/pull/47315. Internally, this lint breaks the build with the following error:

```
shell/platform/android/io/flutter/embedding/android/KeyData.java:78: Error: DeviceType is an enum, which should be immutable, but field DeviceType.value is not final [ImmutableEnum]
    private long value;
    ~~~~~~~~~~~~~~~~~~~
```

See also https://errorprone.info/bugpattern/ImmutableEnumChecker.

Fixes: b/309552840

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-11-07 07:21:23 +00:00
Greg Spencer
0f880e9200 Add KeyEventDeviceType to KeyData (flutter/engine#47315)
## Description

Before we deprecate the `RawKeyEvent` code, it needs to provide parity in functionality. One thing that is missing is the `eventSource` field from the `RawKeyEventDataAndroid` class, which provides the device type for the event.

See https://developer.android.com/reference/android/view/InputDevice#SOURCE_KEYBOARD for an example.

This PR implements that support, and sets the source to `KeyEventDeviceType.keyboard` for platforms that don't provide this information. The main thing it does is add the enum `KeyEventDeviceType`, and a new field `KeyData.deviceType`.

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

## Tests
 - Updated tests to also read/write/verify this property.
2023-11-06 22:58:24 +00:00
Zachary Anderson
2431498922 Move some Dart packages to //flutter/third_party/pkg (flutter/engine#47654)
As part of eliminating the Flutter buildroot
(https://github.com/flutter/flutter/issues/67373), we are moving all
third-party dependencies from //third_party to //flutter/third_party.

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

No tests changed because there is no semantic change to this PR. This is
simply relocating a dependency.
2023-11-06 06:59:27 -08:00
Jason Simmons
cd32fb6c82 Update DisplayList tests to explicitly select the Roboto font (flutter/engine#47493)
Skia is removing the API for constructing a default typeface (see https://issues.skia.org/issues/305780908)

Fixes https://github.com/flutter/flutter/issues/137565
2023-11-02 14:42:00 +00:00
Jason Simmons
cce2f9ced2 Consolidate all the copies of the OpenFixtureAsSkData testing helper function (flutter/engine#47491) 2023-11-01 17:03:05 +00:00
Chris Bracken
44c1e92369 [macOS] Delete FlutterCompositor tests (flutter/engine#47527)
The tests for FlutterCompositor are not useful. The current tests test two things:
1. That the mocks we set up behave the way we set them up to behave.
2. That the implementation of FlutterCompositor is the current implementation of FlutterCompositor.

As an example, consider FlutterCompositorTest.TestPresent: 70317028f2/shell/platform/darwin/macos/framework/Source/FlutterCompositorTest.mm (L107-L137)

Ostensibly, this test verifies that the onPresent callback configured in our fake FlutterViewProvider implementation is called when FlutterCompositor::Present() is called.

However, taking a look at the mocking setup:
70317028f2/shell/platform/darwin/macos/framework/Source/FlutterCompositorTest.mm (L47-L85)

We do the following:
1. Mock out FlutterSurfaceManager such that when a surface is requested, we hand back a mock surface. A little gross since we're relying on some knowledge of implementation details of the compositor, but let's take this as reasonable for now.
2. We mock out `FlutterSurface asFlutterMetalTexture` to return a mock texture. Again, we're getting a bit deep into implementation details that the test shouldn't know about, but let's assume this gets us somewhere.
3. We mock out `FlutterSurfaceManager present:notify:` to actually call the `onPresent` callback if it's passed in.

In effect, we're testing that:
1. We configured our mock for `FlutterSurfaceManager present:notify:` to call onPresent.
2. That `FlutterCompositor::Present` actually calls `FlutterSurfaceManager present:notify:` despite that being a simple implementation detail of that call.

This removes these tests. I have filed the following issue to track refactoring this class for testability and adding tests: https://github.com/flutter/flutter/issues/137648

Encountered these tests as part of deflaking and cleaning up memory allocations throughout the macOS desktop tests.

Issue: https://github.com/flutter/flutter/issues/137648
Issue: https://github.com/flutter/flutter/issues/104789
Issue: https://github.com/flutter/flutter/issues/127441
Issue: https://github.com/flutter/flutter/issues/124840

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-11-01 00:11:52 +00:00
gaaclarke
52fcefb32a Made clang tidy use arm64 if on an arm64 mac. (flutter/engine#47494)
fixes https://github.com/flutter/flutter/issues/137260

## 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

---------

Co-authored-by: Zachary Anderson <zanderso@users.noreply.github.com>
2023-10-31 15:35:36 -07:00
Chris Bracken
6fbf2e7123 [macOS] Wrap external texture tests in autorelease pool (flutter/engine#47492)
Wraps all FlutterExternalTexture tests in an autorelease pool to ensure resources are cleaned up between tests.

Prior to this change, running these tests via:

    ../out/host_debug_unopt_arm64/flutter_desktop_darwin_unittests \
        --gtest_filter='FlutterEmbedderExternalTextureUnittests.*'

Resuling in a segfault:

    [ERROR:flutter/shell/platform/darwin/graphics/FlutterDarwinContextMetalSkia.mm(35)]
    Could not create Metal command queue.
    zsh: segmentation fault
    ../out/host_debug_unopt_arm64/flutter_desktop_darwin_unittests

Issue: https://github.com/flutter/flutter/issues/104789
Issue: https://github.com/flutter/flutter/issues/127441
Issue: https://github.com/flutter/flutter/issues/124840

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-10-30 23:47:18 +00:00
Kevin Lubick
6cf3dac92a Remove call to SkTypeface::MakeDefault (flutter/engine#47344)
Skia plans to remove the default (global) SkFontMgr, which in turn,
requires the removal of a default typeface (e.g. the
typeface returned by `SkTypeface::MakeDefault` and when `nullptr` passed
in to the `SkFont` constructor).

See https://g-issues.skia.org/issues/305780908

## Pre-launch Checklist

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

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

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[test-exempt]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[C++, Objective-C, Java style guides]:
https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
[testing the engine]:
https://github.com/flutter/flutter/wiki/Testing-the-engine
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
2023-10-30 07:48:30 -04:00
gaaclarke
caa9f39916 Made FlutterTaskQueue visible for Swift. (flutter/engine#47348)
fixes https://github.com/flutter/flutter/issues/118832

This makes the `FlutterTaskQueue` protocol visible, but keeps the
`dispatch:` selector private. Under the covers there are runtime checks
to make sure `dispatch:` is available since we can't have compile time
checks anymore.

## Pre-launch Checklist

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

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

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[test-exempt]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[C++, Objective-C, Java style guides]:
https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
[testing the engine]:
https://github.com/flutter/flutter/wiki/Testing-the-engine
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
2023-10-27 11:01:08 -07:00
Zachary Anderson
e1fc52e2b6 Move rapidjson to flutter/third_party (flutter/engine#47354)
As part of eliminating the Flutter buildroot
(https://github.com/flutter/flutter/issues/67373), we are moving all
third-party dependencies from //third_party to //flutter/third_party.

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

No tests changed because there is no semantic change to this PR. This is
simply relocating a dependency.
2023-10-27 08:00:56 -07:00
John McCutchan
632d65292d Don't re-initialize the default RenderSurface when returning from hybrid composition mode (flutter/engine#47358)
When we enter hybrid composition mode we 'pause' the default RenderSurface (implemented by SurfaceView or TextureView) and swap to an ImageReader based RenderSurface.

When we return from hybrid composition mode we recreate and re-initialize the real RenderSurface as if it was being used for the first time.

This broke Platform Views in an internal app b/306122497 because we would incorrectly tell the texture to attach when it was never detached.

This CL changes the protocol so that when we return from hybrid composition mode we only swap the RenderSurface and do not re-create it. This avoids doing a bunch of unnecessary work and fixes the logic error of re-attaching textures that were never detached.

*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-27 00:33:23 +00:00
Tong Mu
a98c3dc263 Skip invalid renders in Dart (flutter/engine#47323)
With this PR, invalid renders are skipped in Dart in both release build and debug build.

Part of https://github.com/flutter/flutter/issues/137073 and part of relanding https://github.com/flutter/engine/pull/45555.

Unit tests will be relanded in a following PR once this PR is confirmed performance-safe.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-10-26 22:09:10 +00:00
Chris Bracken
987dac0ae1 [macOS] Reuse NSWindow instance across unit tests (flutter/engine#47350)
Adds a gtest test fixture mixin and convenience class that instantiates an NSAutoreleasePool at the beginning of each test and flushes it at the end; this allows Objective-C tests using ARC to free  allocations at the end of each test.

Adds a subclass for the macOS accessibility bridge tests that instantiates and re-uses an NSWindow* across any tests that use it. This is because instantiating, closing, and immediately collecting an NSWindow results in a crash.

Prior to this patch, tests started failing (on my machine) around the 855th iteration, and issued the following warning on the 101st iteration:

```
2023-10-26 13:02:45.390829-0700 flutter_desktop_darwin_unittests[40837:1509026] [Window] WARNING: NSWindow has detected an excessive live window count of 101. Window 0x1423 of class 'NSWindow' created after passing the threshold of 100. This window is not necessarily the cause, and this warning will only be shown once per window class. (
  0   AppKit                              0x0000000192820d28 -[NSWindow _setWindowNumber:] + 684
  1   AppKit                              0x00000001933050e4 _NXCreateWindow + 284
  2   AppKit                              0x0000000192901ae0 -[NSWindow _commonAwake] + 672
  3   AppKit                              0x000000019281ff00 -[NSWindow _commonInitFrame:styleMask:backing:defer:] + 972
  4   AppKit                              0x000000019281f798 -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 796
  5   AppKit                              0x000000019281f470 -[NSWindow initWithContentRect:styleMask:backing:defer:] + 48
  6   flutter_desktop_darwin_unittests    0x0000000100001e3c _ZN7flutter7testing89AccessibilityBridgeMacTest_SendsAccessibilityCreateNotificationToWindowOfFlutterView_Test8TestBodyEv + 328
```

See: http://www.openradar.me/FB13291861

Issue: https://github.com/flutter/flutter/issues/104789
Issue: https://github.com/flutter/flutter/issues/127441
Issue: https://github.com/flutter/flutter/issues/124840

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-10-26 21:17:01 +00:00
auto-submit[bot]
24debb363e Reverts "[Impeller] Disable layer tree screenshots." (flutter/engine#47356)
Reverts flutter/engine#46171
Initiated by: jonahwilliams
This change reverts the following previous change:
Original Description:
The "rasterizer screenshot" VM service API uses the Skia software backend, even when running with impeller. At best, this leads to confusing half working screenshots that are missing images.

See https://github.com/flutter/flutter/issues/135052

We should disable this functionality when running with impeller. Perhaps this could be reworked to use picture toImage instead of the offscreen so that it uses the "real" backend regardless of the platform it is running on.

Fixes https://github.com/flutter/flutter/issues/135052
2023-10-26 20:34:17 +00:00
Loïc Sharma
f06b89215e [Windows] Refactor high contrast mode detection (flutter/engine#47314)
This refactors how high contrast is implemented on Windows:

1. Added a test to verify accessibility features are updated when a view is created. This prevents staleness issues as the Windows embedder isn't notified of accessibility changes while in headless mode.
1. Moved high contrast mode detection to `WindowsProcTable` from `FlutterWindow` to remove engine to view to window plumbing.
1. `FlutterWindow` and `FlutterWindowsEngine` now share their `WindowsProcTable` (which is used for mocking and polyfilling win32 APIs) to reduce redundant dynamic loading.

This pull request contains no functional changes.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-10-26 20:22:15 +00:00
Jonah Williams
912c891a1d [Impeller] Disable layer tree screenshots. (flutter/engine#46171)
The "rasterizer screenshot" VM service API uses the Skia software backend, even when running with impeller. At best, this leads to confusing half working screenshots that are missing images.

See https://github.com/flutter/flutter/issues/135052

We should disable this functionality when running with impeller. Perhaps this could be reworked to use picture toImage instead of the offscreen so that it uses the "real" backend regardless of the platform it is running on.

Fixes https://github.com/flutter/flutter/issues/135052
2023-10-26 20:16:09 +00:00
Loïc Sharma
acadeba222 [Windows] Introduce FlutterWindowsViewController (flutter/engine#47242)
This change begins the migration to the Windows embedder's new ownership model:

1. Renames `FlutterDesktopViewControllerState` to `FlutterWindowsViewController`
2. Moves ownership of the `FlutterWindowsEngine` from the `FlutterWindowsView` to the `FlutterWindowsViewController`

For more information, refer to: [flutter.dev/go/windows-multi-view-ownership-updates](https://flutter.dev/go/windows-multi-view-ownership-updates)

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

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-10-25 22:06:16 +00:00
gaaclarke
c2cc73e3e6 Missed linter argument comment violations (flutter/engine#47310)
## 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-25 11:26:11 -07:00
gaaclarke
2b28dc130d Adds lint for checking argument commments (flutter/engine#47305)
[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-10-25 17:21:09 +00:00
gaaclarke
5bfb2200b0 Migrated away from UnmodifiableUint8ListView (flutter/engine#47276)
## 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-24 14:08:45 -07:00
Chinmay Garde
daa95690cd Update fml::ThreadPriority enum to match style guide. (flutter/engine#47255) 2023-10-24 06:14:21 +00:00
Tong Mu
87171e7339 Reland 2: Multiview Pipeline (flutter/engine#47239)
The last attempt https://github.com/flutter/engine/pull/47234 was reverted because there was another test merged in the meantime that violates the rule added in this PR.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-10-23 23:46:25 +00:00
Zachary Anderson
d549483298 Revert "Reland: Multiview pipeline " (flutter/engine#47237)
Reverts flutter/engine#47234

Failures like
https://ci.chromium.org/ui/p/flutter/builders/prod/Mac%20Production%20Engine%20Drone/186568/overview
making the tree red.
2023-10-23 15:17:36 -07:00
Tong Mu
9ed503a734 Reland: Multiview pipeline (flutter/engine#47234)
This PR relands https://github.com/flutter/engine/pull/44473.

The previous PR was immediately reverted after merging because we found that the PR could cause illegal renders to be skipped on debug builds but crash the app on release builds. This PR makes the `Animator::Render` skip illegal renders as well. This should not be the final shape of this feature, and thus a TODO is added.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-10-23 21:35:04 +00:00
Jonah Williams
063c7f54f4 [Impeller] Disable raster stats service protocol. (flutter/engine#47206)
As far as I can tell, this functionality has _always_ been falling back to software rendering with Skia when Impeller was enabled. This is at best extremely misleading. Since I started putting Impeller specific objects in the display list it introduced crashes, and must be disabled.

Fixes https://github.com/flutter/flutter/issues/136847
2023-10-23 18:45:18 +00:00
auto-submit[bot]
47c3403c39 Reverts "Multiview pipeline" (flutter/engine#47174)
Reverts flutter/engine#44473
Initiated by: dkwingsmt
This change reverts the following previous change:
Original Description:
This PR makes `Animator` able to handle multiple views, and updates unit tests accordingly.

Before:
<img width="543" alt="image" src="https://github.com/flutter/engine/assets/1596656/f7d0e0e4-cc85-4a6e-b516-1896ac3c1b35">

After:
<img width="614" alt="image" src="https://github.com/flutter/engine/assets/1596656/68106301-66ef-4cd1-aeaf-d9c6127ccec2">

Now `Animator::Render` must be called during `Animator::BeginFrame`, which is split into `BeginFrame` and `EndFrame`. This requirement is made possible by https://github.com/flutter/engine/pull/45555. The reason to split is to allow `ShellTest::PumpOneFrame` to insert a render from C++ code.

`ShellTest::PumpOneFrame` is also refactored to allow pumping a frame without any views.

A few unit tests are tweaked to resolve racing condition.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-10-20 20:57:08 +00:00
Tong Mu
1cfde62821 Multiview pipeline (flutter/engine#44473)
This PR makes `Animator` able to handle multiple views, and updates unit tests accordingly.

Before:
<img width="543" alt="image" src="https://github.com/flutter/engine/assets/1596656/f7d0e0e4-cc85-4a6e-b516-1896ac3c1b35">

After:
<img width="614" alt="image" src="https://github.com/flutter/engine/assets/1596656/68106301-66ef-4cd1-aeaf-d9c6127ccec2">

Now `Animator::Render` must be called during `Animator::BeginFrame`, which is split into `BeginFrame` and `EndFrame`. This requirement is made possible by https://github.com/flutter/engine/pull/45555. The reason to split is to allow `ShellTest::PumpOneFrame` to insert a render from C++ code.

`ShellTest::PumpOneFrame` is also refactored to allow pumping a frame without any views.

A few unit tests are tweaked to resolve racing condition.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-10-20 20:38:23 +00:00
John McCutchan
5f0a787cdf Lower the severity of a log message (flutter/engine#47172)
This log message can print on the first frame of a platform view and is
not an error.
2023-10-20 13:11:59 -07:00
Chris Bracken
acdd5bb936 [macOS] Eliminate extraneous loadView calls (flutter/engine#47166)
Eliminate unnecessary calls to [NSViewController loadView]. To quote the [documentation][loadview] for this method: "Do not call this method. If you require this method to be called, access the view property."

In several of the existing tests, we do read viewController.view, and the other tests pass without this line regardless.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-10-20 17:30:16 +00:00
Jonah Williams
8031a09e17 [Impeller] GPU Tracer for GLES. (flutter/engine#47080)
Trace GPU execution time on GLES using GL_EXT_disjoint_timer_query. This requires a per-app opt in from the Android Manifest with the key `"io.flutter.embedding.android.EnableOpenGLGPUTracing` set to true.
2023-10-20 17:20:43 +00:00
Chris Bracken
2eae74883a [macOS] Fail early when no a11y notification (flutter/engine#47129)
In the SendsAccessibilityCreateNotificationToWindowOfFlutterView test in AccessibilityBridgeMacTest, we look for an accessibility notification by name in a map stored in the test accessibility bridge. If there is no such notification, bail out immediately.

Previously we got a crash since we called `second` to retrieve the value associated with the map entry we find, without actually checking that we'd actually found an entry.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-10-19 21:52:20 +00:00
Jason Simmons
fa02835346 [Impeller] Use a weak pointer factory in GPUSurfaceGLImpeller that supports the raster thread merger (flutter/engine#47081)
This is required for platform view scenarios that merge the raster task runner into the platform thread.
2023-10-19 20:22:04 +00:00
Jia Hao
0e87f9611e Fix use of nested designators (flutter/engine#45869)
There was an internal global change which turned `-Wc99-designator`. This causes the following error:

```
error: nested designators are a C99 extension [-Werror,-Wc99-designator]
   65 |       .metal.struct_size = sizeof(FlutterMetalRendererConfig),
      |       ^~~~~~~~~~~~~~~~~~
```

This seems like a trivial (?) fix, so perhaps we can fix it properly and possibly remove b9fbd310d6/build/config/compiler/BUILD.gn (L667) after this PR lands.

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

b/300573112

*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-19 18:37:32 +00:00
Tong Mu
6584b2c308 Reland 2 (part 1): Enforce the rule of calling FlutterView.Render (flutter/engine#47062)
This PR relands part of https://github.com/flutter/engine/pull/45300,
which was reverted in https://github.com/flutter/engine/pull/46919 due
to performance regression.

Due to how little and trivial production code the original PR touches, I
really couldn't figure out the exact line that caused it except through
experimentation, which requires changes to be officially landed on the
main branch. After this PR lands, I'll immediately fire a performance
test.

This PR contains the `Shell` refactor of the original PR. I made a
slight change where the isolate snapshot is no longer returned through
return value, but the parameter, in order to avoid the overhead of
assigning.

It is intentional to not contain any unit tests or other changes of the
original PR. They will be landed shortly after this PR.

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

## 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-10-18 14:09:01 -07:00
LongCatIsLooong
fe6ed54c97 [iOS TextInputPlugin] adjust the markedTextRange when replacing text. (flutter/engine#46603)
Fixes https://github.com/flutter/flutter/issues/130880 , by making sure when the text is cleared the `markedTextRange` is cleared with it. 

`[UITextField replaceRange:withText:]` always sets the selection range to the end of the replacement text, and removes the current `markedTextRange`. This PR makes the input plugin do the same in the `replaceRange:withText:` implementation.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-10-18 20:33:14 +00:00
Jia Hao
717b750145 Add missing source file (flutter/engine#47046)
Maybe I'm missing something here. It seems like we include this file below:

dae6a4deb4/shell/platform/embedder/pixel_formats.cc (L5)

But it isn't mentioned in the gn file. Not sure how it is actually working today.
2023-10-18 16:13:12 +00:00
Matej Knopp
6054dbd0cb [macOS] Fix tests failing on Sonoma (flutter/engine#46461)
1. Using arbitrary struct passed as const reference  to `OCMStub` now fails in OCMock. Down the line this will result with `object_getClass` being called in [`OCMArg.m`](https://github.com/erikdoe/ocmock/blob/master/Source/OCMock/OCMArg.m#L129-L133) with the address of the reference, which is not a valid class instance. This seems to have worked pre-sonoma, but it seems like a weird thing to rely on.

2. `NSResponder` mock can not be set to view controller anymore. The controller will try to access an ivar of the `NSResponder`, but mocked responder does not have the ivar of original objects which will result on invalid selector being called on a `NSMutableArray` one of the ivar of mock objects. Solution for this is to inherit from `NSResponder` and forward calls to mocked object.

3. Adding `flutter::kModifierFlagShiftLeft` to a modifier flag containing `kCGEventFlagMaskShift`. The assertion was introduced in https://github.com/flutter/engine/pull/46230 but i missed the test failure because of the problems above.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-10-18 04:52:19 +00:00
LongCatIsLooong
d4211a976b Don't respond to the insertionPointColor selector on iOS 17+ (flutter/engine#46373)
Fixes https://github.com/flutter/flutter/issues/132548

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-10-17 19:03:48 +00:00
Jason Simmons
91cf2a899f Revert "Fix Platform.script for flutter_tester" (flutter/engine#46981)
This reverts commit 670b5bd8e714a1fd2bd137aa2c5b36760b8ce89b.

With https://github.com/flutter/engine/pull/46911, the Platform.script API will return a URI for the compiled temporary wrapper script generated by "flutter test".  This will cause issues for tests that expect Platform.script to reflect the directory where "flutter test" was launched.
2023-10-17 01:07:02 +00:00
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