4905 Commits

Author SHA1 Message Date
Rulong Chen(陈汝龙)
ba2b335b99 Fix NPE when platform plugin delegate is null (flutter/engine#49391)
Fixes: 
https://github.com/flutter/flutter/issues/140600
https://github.com/flutter/flutter/issues/140031

## Pre-launch Checklist

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

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

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[test-exempt]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[C++, Objective-C, Java style guides]:
https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
[testing the engine]:
https://github.com/flutter/flutter/wiki/Testing-the-engine
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
2024-01-02 08:54:39 -08:00
Rulong Chen(陈汝龙)
62abbc2a03 Add try-with-resource support to TraceSection (flutter/engine#49445)
This PR adds a new way to define scoped trace events in Java, using the try-with-resource construct. This makes code simpler to read, and less error-prone.

Before:
```java
try {
  TraceSection.begin("name");
  // ....
} finally {
  TraceSection.end();
}
```

Now:
```java
try (TraceSection e = TraceSection.scoped("name")) {
  // ...
}
```

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-01-02 16:35:19 +00:00
Loïc Sharma
e7b8646416 [Windows] Move DWM flush to Windows proc table for mocking (flutter/engine#49398)
The `FlutterWindowsView` uses the `DwmFlush` win32 API to prevent artifacts during window resizing.

Currently, the view used the `FlutterWindow` to allow mocking this win32 API. However, the window is a complex type with lots of other responsibilities. The `WindowsProcTable` is the new preferred type for mocking win32 API.

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

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-12-27 23:41:19 +00:00
Loïc Sharma
ed5f58647f [Windows] Move DWM composition status to Windows proc table for mocking (flutter/engine#49397)
The `FlutterWindowsView` needs the `DwmIsCompositionEnabled` win32 API to check whether it should block presents until the v-blank to prevent screen tearing.

Currently, the view used the `FlutterWindow` to allow mocking this win32 API. However, the window is a complex type with lots of other responsibilities. The `WindowsProcTable` is the new preferred type for mocking win32 API.

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

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-12-26 23:08:34 +00:00
Loïc Sharma
e18aa559bd [Windows] Remove PlatformWindow and RenderTarget abstractions (flutter/engine#49312)
The Windows embedder has three ways to get an `HWND`:

1. `GetWindowHandle` which returns the `HWND`
2. `GetPlatformWindow` which returns the `HWND` wrapped as a `PlatformWindow`
3. `GetRenderTarget` which returns the `HWND` wrapped as a `RenderTarget`

These abstractions are no longer useful now that we removed the UWP embedder. This change removes `PlatformWindow` and `RenderTarget` and uses `HWND` directly.

This change is a refactoring with no semantic changes.
2023-12-26 19:34:06 +00:00
Loïc Sharma
6e4ab692e7 [Windows] Fix incorrect surface manager comment (flutter/engine#49335)
https://github.com/flutter/engine/pull/24428 attempted to make surface resizing less expensive by using ANGLE's automatic resizing instead of manually destroying and then re-creating the surface. This caused 
some issues:

1. Flutter's surface size synchronization logic broke: https://github.com/flutter/engine/pull/24682
2. Resizing frameless windows caused the content to wiggle: https://github.com/flutter/flutter/issues/76465

The second issue caused the automatic resizing change to be reverted. However, the first fix was not reverted resulting in an incorrect comment.

Relanding this resizing performance improvement is tracked by https://github.com/flutter/flutter/issues/79427
2023-12-21 21:58:41 +00:00
Loïc Sharma
f3381e1080 Reland "[Windows] Move to FlutterCompositor for rendering" (flutter/engine#49262)
## Reland

https://github.com/flutter/engine/pull/48849 was reverted as it incorrectly expected to receive always 1 layer. However, the engine will present 0 layers on an ["empty" app](6981fe6fd3/dev/integration_tests/ui/lib/empty.dart (L8-L19)). This pull request is split into two commits:

1. df604a16c0 is the original pull request, unchanged
2. c30b369289 adds the ability to "clear" the view if the engine presents 0 layers

## Original pull request description

This migrates the Windows embedder to `FlutterCompositor` so that the engine renders off-screen to a framebuffer instead of directly onto the window's surface. This will allow us to support platform views and multiple views on Windows.

Addresses https://github.com/flutter/flutter/issues/128904

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-12-21 01:23:20 +00:00
Bartek Pacia
94d48e76c1 SemanticsUpdateBuilder: make all args non-null (flutter/engine#49148)
This PR is inspired by [the suggestion made here](https://github.com/flutter/engine/pull/47961#discussion_r1406581284).
2023-12-20 22:41:13 +00:00
Tong Mu
2e551cb5c3 Multi-view pointer event (flutter/engine#46213)
This PR adds a new field `view_id` to embedder API's `FlutterPointerEvent`, allowing platforms to specify the source view of pointer events.

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

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-12-20 19:21:22 +00:00
Sergiy Dubovik
b7264de08d [macos] FlutterKeyboardManager memory leak fix (flutter/engine#48824)
We are embedding Flutter into MacOS app, and noticed that there is a
leak. `leaks` tool says there is a cycle reference:

```
12 (2.11K) ROOT CYCLE: <FlutterKeyboardManager 0x29ec55f40> [80]
       8 (432 bytes) __strong _primaryResponders --> ROOT CYCLE: <NSMutableArray 0x29ec560a0> [64]
          7 (368 bytes) ROOT CYCLE: <NSMutableArray (Storage) 0x29ec56140> [32]
             4 (224 bytes) ROOT CYCLE: <FlutterEmbedderKeyResponder 0x29ec56310> [80]
                1 (48 bytes) __strong _sendEvent --> ROOT CYCLE: <__NSMallocBlock__ 0x29ec56360> [48]
                   __strong [capture] --> CYCLE BACK TO <FlutterKeyboardManager 0x29ec55f40> [80]
                1 (48 bytes) __strong _pendingResponses --> <NSMutableDictionary 0x29ec563c0> [48]
                1 (48 bytes) __strong _pressingRecords --> <NSMutableDictionary 0x29ec56390> [48]
             2 (112 bytes) <FlutterChannelKeyResponder 0x29ec56450> [48]
                1 (64 bytes) __strong _channel --> <FlutterBasicMessageChannel 0x29ec564e0> [64]
       2 (1.55K) __strong _layoutMap --> <NSMutableDictionary 0x29ec56630> [48]
          1 (1.50K) <NSMutableDictionary (Storage) 0x123c34a00> [1536]
       1 (64 bytes) __strong _pendingEvents --> <NSMutableArray 0x29ec565f0> [64]
```

This patch uses `weak` pointer to `self` instead of implicit `strong`.

## 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.
2023-12-20 09:04:10 -08:00
Zachary Anderson
971c03d9e3 Rolls clang to 725656bdd885483c39f482a01ea25d67acf39c46 (flutter/engine#49248)
We're on a version of clang that crashes a lot on macOS. This PR rolls
clang forward to a new release from the Fuchsia toolchain team. If it
does not fix the crash, we can roll back with
https://github.com/flutter/engine/pull/49249. Both rolling forward and
back require the fixes to the `.mm` file in this PR.
2023-12-19 13:35:42 -08:00
John McCutchan
294a05da81 Use new SurfaceProducer external texture class for rendering platform views (flutter/engine#49201)
- Fix lots of bugs in the implementation of ImageReaderSurfaceProducer
- Add test that we drop frames produced from the wrong size
- Hookup platform views to use new external texture class

Related: [#139230](https://github.com/flutter/flutter/issues/139230)
Related: [#139702](https://github.com/flutter/flutter/issues/139702)
2023-12-19 10:08:46 -08:00
Code Otaku
7f0343f6fc Makes PlatformViewsController view to use tracked event's action & pointer count (flutter/engine#47424)
related issue https://github.com/flutter/flutter/issues/111268,
https://github.com/flutter/flutter/issues/106190

### Motivation:
- At https://github.com/flutter/flutter/issues/111268, we found that
Android PlatformView scrolls slowly after #34182 commit

### Modification:
- Makes `PlatformViewsController` view to use `tracked event`'s action &
pointer count

### Result:
- Now PlatformView scrolls not slowly
- Close https://github.com/flutter/flutter/issues/111268,
https://github.com/flutter/flutter/issues/106190


- [ ] 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], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [ ] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] All existing and new tests are passing.

Co-authored-by: John McCutchan <john@johnmccutchan.com>
2023-12-18 20:41:02 -08:00
Matej Knopp
33a6339c63 Add FlutterMetalLayer as optional alternative to CAMetalLayer (flutter/engine#48226)
This PR implements `FlutterMetalLayer`, a drop-in (as far as Flutter is
concerned) replacement for `CAMetalLayer`. The biggest difference is
that `FlutterMetalLayer` can present frames from background thread
within a `CATransaction`.

`FlutterMetalLayer` is disabled by default. To opt-in, add the following
item to `Info.plist`:

```xml
        <key>FLTUseFlutterMetalLayer</key>
	<true/>
```

The performance seems quite good, consistent 120hz on iPhone 13 Pro.

Benefits
- presenting with transaction from background thread, which, down the
line, would allow for platform views without thread merging.
- fine control over how the surface is displayed - we can display single
surface on multiple `CALayers`, each showing different part, allowing
for performant implementation of unobstructed platform views.
 
Drawbacks
- this not being a metal layer makes working with metal instrument tools
more awkward
2023-12-16 21:53:32 +01:00
gaaclarke
a53bf6a572 [Impeller] split out gradient tests from aiks_unittests (flutter/engine#49050)
issue https://github.com/flutter/flutter/issues/140106

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-12-15 01:12:53 +00:00
Matan Lurey
02f6c46771 Fix header-guard naming convention in shell/. (flutter/engine#49006)
Part of landing https://github.com/flutter/engine/pull/48903.

Some of these actually seem like potential owchy spots, i.e. `#ifndef FLUTTER_FLUTTER_H_`.
2023-12-14 23:37:22 +00:00
Lau Ching Jun
2363abacfe Suppress warning for the new Activity library. (flutter/engine#49046)
Context: cl/582573869
2023-12-14 23:09:54 +00:00
Jenn Magder
2d0010fcb6 Fix NSPrivacyCollectedDataTypes array in privacy manifest (flutter/engine#49041)
In https://github.com/flutter/engine/pull/48951 `NSPrivacyCollectedDataTypes` is an array with an empty dictionary, but the privacy report wants an empty array or it errors:

<img width="523" alt="Screenshot 2023-12-14 at 10 02 52 AM" src="https://github.com/flutter/flutter/assets/682784/a128b384-db2f-49d7-8b71-7965f2826de8">

When this is fixed the privacy report is blank, but that seems to be an Xcode bug?  Will investigate.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-12-14 20:26:05 +00:00
Loïc Sharma
d5968a10c0 [Windows] Remove header guard from generated key map (flutter/engine#48993)
No tests as this is a refactoring with no semantic changes.

The generator was updated by https://github.com/flutter/flutter/pull/140082
2023-12-14 19:50:05 +00:00
Bruno Leroux
6162b4211f [Windows] Expose channel buffers 'resize' and 'overflow' control commands exposed by the control channel. (flutter/engine#47158)
## Description

This PR adds two helper functions to invoke the 'resize' and 'overflow' commands exposed by the control channel.
See:

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

Implementation based on the discussion from https://github.com/flutter/engine/pull/46998.

## Related Issue

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

## Tests

Adds 4 tests.
2023-12-14 15:56:56 +00:00
auto-submit[bot]
171873ec88 Reverts "[Windows] Move to FlutterCompositor for rendering" (flutter/engine#49015)
Reverts flutter/engine#48849
Initiated by: loic-sharma
This change reverts the following previous change:
Original Description:
This migrates the Windows embedder to `FlutterCompositor` so that the engine renders off-screen to a framebuffer instead of directly onto the window's surface. This will allow us to support platform views and multiple views on Windows.

<details>
<summary>Tests...</summary>

* Verify OpenGL compositor's raster time isn't regressed and memory increase is reasonable
* Software compositor's raster time and memory isn't regressed

Test device configurations
* [x] Windows 11 (hardware acceleration enabled/disabled)
* [x] Windows Arm64 (hardware acceleration enabled/disabled)
* [x] Windows 7 (hardware acceleration enabled/disabled, DWM enabled/disabled)

</details>

Addresses https://github.com/flutter/flutter/issues/128904

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-12-14 05:03:20 +00:00
Jenn Magder
85abc44624 Add xcprivacy privacy manifest to iOS framework (flutter/engine#48951)
Create a `PrivacyInfo.xcprivacy` (this name is required) plist and move it to the top-level of the iOS framework bundle.  `NSPrivacyTracking*` and `NSPrivacyCollectedDataTypes` keys are required, but the values are blank.

Apple [now requires](https://developer.apple.com/documentation/bundleresources/privacy_manifest_files) that third-party frameworks must include this manifest to document usage of particular APIs and [how they are used](https://developer.apple.com/documentation/bundleresources/privacy_manifest_files/describing_use_of_required_reason_api).

> Starting in fall 2023, when you upload a new app or app update to App Store Connect that uses an API (including from third-party SDKs) that requires a reason, you’ll receive a notice if you haven’t provided an approved reason in your app’s privacy manifest. And starting in spring 2024, in order to upload your new app or app update to App Store Connect, you’ll be required to include an approved reason in the app’s privacy manifest which accurately reflects how your app uses the API.

https://developer.apple.com/news/?id=z6fu1dcu

@stuartmorgan [audited](https://github.com/flutter/flutter/issues/131494#issuecomment-1852718759) the engine and third_party:

> * File timestamps:
>   
>   * `C617.1` for app state restoration in `FlutterAppDelegate.mm`.
>   * `0A2A.1` for implementation of the relevant `File` wrappers.
> * System boot time:
>   
>   * `35F9.1` for various event timing and elapsed time calculations.

Note macOS frameworks do not need to declare `NSPrivacyAccessedAPITypes`.
I don't think this will require recipe or conductor codesign changes since this is a file copied as a resource into the framework, just as the modulemap and Info.plist aren't referenced anywhere.

I'm not quite sure how to test this other than letting it build and generate a `Generate Privacy Report` in a Flutter app in Xcode.  There's no where we check that, say, the Info.plist is copied to the right place in Flutter.framework (even in flutter/flutter).  When this rolls into the framework I will add a check to [ios_content_validation_test.dart](3da9bc1698/dev/devicelab/bin/tasks/ios_content_validation_test.dart)

On this PR the `PrivacyInfo.xcprivacy` was written to the expected location in the Flutter.framework:
d45cd08094/516/tree

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

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-12-14 01:37:59 +00:00
Loïc Sharma
d5a40e1093 [Windows] Move to FlutterCompositor for rendering (flutter/engine#48849)
This migrates the Windows embedder to `FlutterCompositor` so that the engine renders off-screen to a framebuffer instead of directly onto the window's surface. This will allow us to support platform views and multiple views on Windows.

<details>
<summary>Tests...</summary>

* Verify OpenGL compositor's raster time isn't regressed and memory increase is reasonable
* Software compositor's raster time and memory isn't regressed

Test device configurations
* [x] Windows 11 (hardware acceleration enabled/disabled)
* [x] Windows Arm64 (hardware acceleration enabled/disabled)
* [x] Windows 7 (hardware acceleration enabled/disabled, DWM enabled/disabled)

</details>

Addresses https://github.com/flutter/flutter/issues/128904

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-12-13 23:21:56 +00:00
Loïc Sharma
5139925e3b [Windows] Refactor surface manager mocking (flutter/engine#48953)
See: https://github.com/flutter/engine/pull/48849#discussion_r1424535869
2023-12-13 17:42:52 +00:00
Jason Simmons
df2ac7aeb6 Workarounds for clang-tidy warnings in the next roll of Clang (flutter/engine#48963)
See https://github.com/flutter/engine/pull/48928
2023-12-13 03:27:04 +00:00
Bartek Pacia
d3b6e4044d SemanticsUpdateBuilder migration: introduce identifier (flutter/engine#48882)
This PR adds `String? identifier` to `SemanticsUpdateBuilder` (currently it's only available in the temproary `SemanticsUpdateBuilderNew` API.

This is mainly targeted at https://github.com/flutter/flutter/issues/17988

Steps:
part 1: [engine] add `SemanticsUpdateBuilderNew` https://github.com/flutter/engine/pull/47961
part 2: [flutter] use `SemanticsUpdateBuilderNew`  https://github.com/flutter/flutter/pull/138331
**part 3: [engine] update `SemanticsUpdateBuilder` to be the same as `SemanticsUpdateBuilderNew`** <-- we are here
part 4: [flutter] use (now updated) `SemanticsUpdateBuilder` again.
part 5: [engine] remove `SemanticsBuilderNew`
2023-12-11 22:35:07 +00:00
Bartek Pacia
de91195bb1 Add support for exposing accessibility identifier as accessibilityIdentifier on iOS (flutter/engine#48858)
This PR is a sibling of #47961 but for iOS
2023-12-11 22:35:06 +00:00
Zachary Anderson
63e00ce106 Fix _availability_version_check for iOS 11 and 12 (flutter/engine#48624)
This PR ports more of the implementation of availability checking from
clang-rt into the Engine. In particular, when the call to look up the
symbol `_availability_version_check` fails, this PR falls back on
reading the platform version information out of a plist file at a
well-known location, as is done
[here](2fd66e6eb6/compiler-rt/lib/builtins/os_version_check.c (L163)).

This change fixes a mistake in
https://github.com/flutter/engine/pull/44711, which didn't account for
`_availability_version_check` not being available on iOS 11 and 12.

Fixes https://github.com/flutter/flutter/issues/138711
2023-12-11 11:51:55 -08:00
John McCutchan
c9528be3c6 Add a new external texture type to Android embedder (flutter/engine#48803)
The `SurfaceProducer` interface exposes only exposes a Surface to render
on, abstracting away the consumer side of the external texture.

The `ImageReaderSurfaceProducer` implementation of this interface is
included as well as a basic test of that code.

Also, a small refactor so that `ImageTexture` and
`ImageReaderSurfaceProducer` can use the same native C++ code in the
engine.

Subsequent CLs will need to address the following:

- A SurfaceTextureSurfaceProducer (your eyes are probably bleeding from
that name) implementation is needed so we can support GL based systems.
- Update Platform Views to use this new SurfaceProducer type instead of
the legacy types.
- Deprecate SurfaceTexture and ImageTexture external texture types.

Related issue
[#139702](https://github.com/flutter/flutter/issues/139702)
2023-12-08 13:20:51 -08:00
Jason Simmons
09e12e0f51 Reland "Replace use of Fontmgr::RefDefault with explicit creation calls" (flutter/engine#48764)
Relands https://github.com/flutter/engine/pull/48571 with a patch that uses the directory-based SkFontMgr as a default font manager on Linux
2023-12-07 15:45:08 +00:00
Jason Simmons
6f48ab3443 Revert "Replace use of Fontmgr::RefDefault with explicit creation calls" (flutter/engine#48755)
This reverts commit d5d8b5de90f40644f23d309c0f68d03e299334eb.

The flutter/tests/skp_generator test (running in flutter_tester on
Linux) was failing, along with some customer tests.
2023-12-06 17:50:14 -08:00
Loïc Sharma
ea34df3c56 [Windows] Set swap interval on raster thread after startup (flutter/engine#47787)
The EGL context can only be used by a single thread at a time. Currently:

1. The platform thread uses the EGL context to configure the render surface when a `FlutterViewController` is created
2. The raster thread uses the EGL context to render

In a multi-view world, a `FlutterViewController` can be created in parallel to a rendering operation. This results in multiple threads attempting to use the EGL context in parallel, which can crash (see https://github.com/flutter/flutter/issues/137973).

This change configures the render surface on the raster thread if the raster thread exists (aka the engine is running).

Addresses https://github.com/flutter/flutter/issues/137973

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-12-06 18:44:17 +00:00
Loïc Sharma
6c6f23360c [Windows] Refactor the GLES proc table (flutter/engine#48688)
GLES functions are resolved at runtime. This refactors how these functions are stored by introducing the `GlProcTable` abstraction.

This is a step towards switching the Windows embedder to `FlutterCompositor` rendering as the present callback will use the `GlProcTable` to render OpenGL backing stores.
 
Part of https://github.com/flutter/flutter/issues/128904

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-12-06 18:19:36 +00:00
Kevin Lubick
d5d8b5de90 Replace use of Fontmgr::RefDefault with explicit creation calls (flutter/engine#48571)
In https://g-issues.skia.org/issues/305780908 Skia is removing the
default SkFontMgr. Previous work consolidated all references to
txt/platform.h and this replaces those last references. I attempted to
mirror the existing functionality, which still responds to GN flags and
the target platform.

After this PR, Flutter should not be depending on the default fontmgr
(and the defines in flutter_defines.gni) will maintain that behavior
until the legacy functions/methods are deleted from Skia. There were a
few tests that I missed on an earlier PR which relied on the default
font (helper added in #47493). These tests were failing because they
were making some assertions related to TextBlobs, which didn't work if
the (now-empty) Typeface they loaded had no glyphs. Thus, I added a few
extra asserts to make sure these textblobs *had* glyphs which make the
failing tests less mysterious, should this issue crop up again.

I cleaned up Flutter's BUILD.gn file for Skia a bit, deleting unused
targets related to the font managers. This involved fixing an implicit
dependency from //third_party/glfw/ to `Gdi32.lib` on Windows.

## Pre-launch Checklist

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

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

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[test-exempt]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[C++, Objective-C, Java style guides]:
https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
[testing the engine]:
https://github.com/flutter/flutter/wiki/Testing-the-engine
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
2023-12-06 13:02:34 -05:00
Jonah Williams
82a8b5ddcf [Impeller] Vulkan framebuffer fetch via VK_ARM_RASTERIZATION_ORDER_ATTACHMENT_ACCESS (flutter/engine#48458)
Support framebuffer fetch on devices that have the extension VK_ARM_RASTERIZATION_ORDER_ATTACHMENT_ACCESS which gives us a fairly easy way to add subpass self dependencies.

Part of https://github.com/flutter/flutter/issues/120223
2023-12-06 00:55:59 +00:00
Chinmay Garde
4a1f8fa2f3 Avoid non-const sizes in VLAs. (flutter/engine#48693)
I was shocked this was even legal earlier. But a new Clang roll makes this an a warning which gets converted into an error.

I attempted to roll to the Clang roll the roller did and fixed the issues I found. Hopefully, the next roll is unblocked.

Original failure: https://github.com/flutter/engine/pull/48563
2023-12-05 21:11:23 +00:00
Jonny Wang
8a83072ebc A11y enabled state (flutter/engine#48653)
Sets enabled state in Fuchsia a11y via the accessibility bridge.

This was added in Fuchsia API v15, which Flutter is updated to use after
#48233.

b/261482081

## 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.
2023-12-05 18:17:28 +00:00
Loïc Sharma
20e5300477 [Windows] Decouple the GL context from the view (flutter/engine#48636)
In the future, the GL context will be shared between zero or more views. The engine will also need to be able to make the GL context current even if the app is currently in headless mode.

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

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-12-04 20:53:03 +00:00
Tong Mu
673fca77cf Multiview ExternalViewEmbedder (flutter/engine#46169)
This PR adds multiview support for `ExternalViewEmbedder`.

## Nomenclature

The term **view** can be ambiguous in `ExternalViewEmbedder`, and therefore the following terms are used:
* A **native view** refers to the final drawing surface that to composite layers to. It is the "view" used in other places of the engine, such as `Shell::AddView`.
* A **platform view** refers a platform view, a layer that holds content to be embedded.

## Change

The lifecycle of `ExternalViewEmbedder` is changed:

<table>
    <thead>
        <tr>
            <th>Before PR</th>
            <th>After PR</th>
            <th>How it's called</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td rowspan=2>BeginFrame</td>
            <td>BeginFrame</td>
            <td>Once per frame</td>
        </tr>
        <tr>
            <td>PrepareFlutterView</td>
            <td>Once per flutter view</td>
        </tr>
        <tr>
            <td>SubmitFrame</td>
            <td>SubmitFlutterView (renamed)</td>
            <td>Once per flutter view</td>
        </tr>
        <tr>
            <td>EndFrame</td>
            <td>EndFrame (unchanged)</td>
            <td>Once per frame</td>
        </tr>
    </tbody>
</table>

* `BeginFrame` should perform per-frame actions, such as merge-unmerging threads.
* `PrepareView` should perform per-native-view preparations, such as recording the view ID and view size.

This change is necessary because some actions in `PrepareView` needs to be refreshed at the beginning of drawing every native view.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-12-04 20:29:49 +00:00
Bartek Pacia
79126777a4 Add support for exposing accessibility identifier as resource-id on Android (flutter/engine#47961)
Accompanying framework PR: https://github.com/flutter/flutter/pull/138331

This PR implements support for exposing `SemanticsProperties.identifier` on Android as `resource-id`. Mainly targeted at https://github.com/flutter/flutter/issues/17988. Would also fix https://github.com/flutter/flutter/issues/issues/137735 but it was marked as duplicate. Anyway, there's a lot of context in that issue.

This PR requires changing the `SemanticsUpdateBuilder` interface (defined in engine) that framework depends on, so it requires introducing a temporary API ([see question I asked on Discord](https://discord.com/channels/608014603317936148/608018585025118217/1174845658033819729) to learn more about this approach).

Steps:
**part 1: [engine] add `SemanticsUpdateBuilderNew`** <-- we are here
part 2: [flutter] use `SemanticsUpdateBuilderNew`
part 3: [engine] update `SemanticsUpdateBuilder` to be the same as `SemanticsUpdateBuilderNew`*
part 4: [flutter] use (now updated) `SemanticsUpdateBuilder` again.
part 5: [engine] remove `SemanticsBuilderNew`

I'd like to do these changes first, and only then continue with [the proper framework PR](https://github.com/flutter/flutter/pull/138331).

*More specifically: update `SemanticsUpdateBuilder.updateNode()` to be the same as `SemanticsUpdateBuilderNew.updateNode()`. Number of arguments that function takes is the only change.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-12-04 19:27:18 +00:00
Matan Lurey
6e99e081fe Roll a new version of googletest (2021->2023). (flutter/engine#48285) 2023-11-30 17:50:30 -08:00
Camille Simon
7965fd759e [Android] Check for text to paste before trying to retrieve data from URI (flutter/engine#48166)
Adds a check to retrieve explicit text from Clipboard items via [`getText`](https://developer.android.com/reference/android/content/ClipData.Item#getText()) before attempting to retrieve data if the Clipboard item (`ClipData.Item`) has an associated URI. Also adds more error handling for edge cases concerning URIs (the URI not having the content scheme or being null).

Fixes https://github.com/flutter/flutter/issues/74320. Some content providers will not send URIs containing the `text/*` pattern or have the content scheme (`content://`), but ultimately we should expect Clipboard items to either fall **not** into one of those categories or have an explicit textual value available via `getText`. In case this is not true, though, checks for non-content URIs and null URIs are added, as well :)

Tested on a Samsung tablet with pasting from MS Word, MS Excel, and Samsung Notes.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-12-01 00:04:42 +00:00
Loïc Sharma
f5cacea14a [Windows] Begin decoupling text input plugin from the view (flutter/engine#47833)
Currently the text input plugin is strongly tied to a single view. This change makes the text input plugin tied to the engine in preparation for multi-view world.

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

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-11-30 21:49:14 +00:00
Bruno Leroux
2a59992ea5 [Android] Add support for the PlatformChannel "Share.invoke" command (flutter/engine#48265)
## Description

This PR adds support for the PlatformChannel `Share.invoke` message on Android (before this PR it is only supported on iOS).

## Related Issue

Engine side for https://github.com/flutter/flutter/issues/138728

## Tests

Adds 2 tests.
2023-11-30 06:12:11 +00:00
Gray Mackall
b9b16eab3c Fix new lint from android 14 upgrade, and remove it from the baseline (flutter/engine#47817)
See https://github.com/flutter/engine/pull/47609#discussion_r1385803721 for context.

It isn't clear to me what the file descriptor here is actually doing, so I'm not actually too sure about this fix. Can it just be deleted?

Update: it seems to me that the motivation here is that `ClipData.Item.coerceToText` [consumes a `SecurityException` here](https://cs.android.com/android/platform/superproject/main/+/main:frameworks/base/core/java/android/content/ClipData.java;l=411;bpv=0;bpt=1), with just a log line that isn't particularly descriptive. And basically we want to run into that same exception so we can [provide a more helpful log line](e5da8d9a87/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java (L525)), so we do the same thing that the underlying `coerceToText` method does?

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-11-29 16:04:20 +00:00
auto-submit[bot]
8c6313074f Reverts "binary_messenger missing cstdint" (flutter/engine#48483)
Reverts flutter/engine#48481
Initiated by: matanlurey
This change reverts the following previous change:
Original Description:
This PR adds cstdint to binary_messenger.h.  Without this building plugin support for generic Linux fails.  Not related to the GTK source tree.

*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-11-29 02:25:18 +00:00
Joel Winarske
26853f24e2 binary_messenger missing cstdint (flutter/engine#48481)
This PR adds cstdint to binary_messenger.h.  Without this building plugin support for generic Linux fails.  Not related to the GTK source tree.

*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-11-29 02:17:22 +00:00
Robert Ancell
297a817fc9 Fix the application not disposing by breaking circular references on quit (flutter/engine#47684)
GtkApplication windows contain a reference back to the application. This
means the MyApplication object in the Flutter application never
disposes. We workaround this by removing these references before we
quit. This occurs for all GTK applications that quit using this method,
see https://gitlab.gnome.org/GNOME/gtk/-/issues/6190. This may be fixed
upstream at some point but the proposed workaround should solve the
problem for all versions and not conflict with any upstream solution.

Fixes https://github.com/flutter/flutter/issues/136582
2023-11-29 14:01:53 +13:00
Matan Lurey
92a2b041fb Update HeaderFilterRegex once and for all. (flutter/engine#48145)
Includes a test (`header_filter_regex_test.dart`) that hopefully keeps
us on rails going forward.
2023-11-27 15:30:18 -08:00
hangyu
4f5a0eef4c [ios] Send " did gain focus" message from engine to framework (flutter/engine#48252)
issue: https://github.com/flutter/flutter/issues/97747

framework pr :https://github.com/flutter/flutter/pull/135771 
android pr: https://github.com/flutter/engine/pull/47114

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-11-27 20:22:53 +00:00