3333 Commits

Author SHA1 Message Date
Harry Terkelsen
20ef29732d Reland "[web] Enforce onDrawFrame/onBeginFrame render rule" (flutter/engine#49336)
Enforces the render rule on the web except in the HTML renderer, which
must still render to the DOM even outside of `onDrawFrame` or
`onBegineFrame` scopes in order for golden tests to continue to work in
the framework.

This is a reland of https://github.com/flutter/engine/pull/49214 with
one change (checking for `renderer.rendererTag == 'html'` in the
`render` method).

## 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-12-21 13:10:27 -08:00
Chris Bracken
535bb52c87 Revert onrender change (flutter/engine#49333)
This reverts https://github.com/flutter/engine/pull/49214 and
https://github.com/flutter/engine/pull/48758.

https://github.com/flutter/engine/pull/49214 appears to cause a Flutter
Gold diff during the engine roll. See
https://github.com/flutter/flutter/pull/140434 for an example. It's
unclear to me whether this is an expected diff and should be approved or
unexpected and should be reverting, so reverting to the last previous
rollable state.

## 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-12-21 11:00:30 -08:00
Yegor
409fb68d25 [web] autofocus in new routes (flutter/engine#47727)
Fixes https://github.com/flutter/flutter/issues/138371

When a new route pops up the expectation is that the screen reader focuses on something in the new route. Since routes typically result in DOM nodes being replaced, the current effect is that the screen reader simply unfocuses from the page, causing the user to have to refocus on back on the page and look for elements to interact with, which is a poor user experience. The current workaround is to use `autofocus`, but that doesn't scale as it's easy to forget, and if the route in question is maintained by a different person you may not even have enough control over it to set `autofocus` on anything. For example, this is the case with Flutter's default date picker. All you have is `showDatePicker` and there's no way to control the focus.

With this change the route (managed by the `Dialog` primary role) will check if a widget requested explicit focus (perhaps using `autofocus`), and if not, looks for the first descendant that a screen reader can focus on, and requests focus on it. The auto-focused element does not have to be literally focusable. For example, plain `Text` nodes do not have input focus (i.e. they are not `isFocusable`) but screen readers can still focus on them. If such an element is found, the web engine requests that the browser move focus to it programmatically (`element.focus()`), which causes the screen reader to move the a11y focus to it as well, but it sets `tabindex=-1` so the element is not focusable via keyboard or mouse.
2023-12-21 18:11:13 +00:00
Jim Graham
910a5fa5d8 Ensure sorted rects in ui.Canvas for legacy compatibility (flutter/engine#49309)
Fixes https://github.com/flutter/flutter/issues/140490
2023-12-21 08:34:23 +00:00
Dan Field
ae9289f5c1 [Impeller] Make IPLR files multi-platform (flutter/engine#49253)
This is part of the work towards supporting OpenGLES and Vulkan for runtime stage shaders.

Removes some redundant work we had around SkSL. Now only bundles the shaders we actually ask for from the command line.

@bdero, we should figure out if this is the right approach for flutter_gpu.

With this change, the IPLR format goes from having a root table of shader related information to a root table of shader information per `sksl`, `metal`, `opengles`, and `vulkan` platforms. 

This may end up allowing us to revert https://github.com/flutter/engine/pull/47278, but I'm not sure I understand all the implications of that at this point.

I have run some but not all tests locally.
2023-12-21 06:17:26 +00:00
David Iglesias
b3b7451d1e [web] Defer injection of platform views until needed. (flutter/engine#48960)
This PR defers the injection of the contents of a Platform View into the DOM of the page, until the Platform View is really needed by a renderer.

This effectively means that a `platformView` will be injected into the DOM the first time that its `slot` is injected into the Shadow DOM of the Flutter web app.

This makes passing a `(flutter)ViewId` parameter from the framework unnecessary, even in a multi-view app.

The only cases in which this change might be breaking is those where an app tries to locate the just-created Platform View by looking into the DOM from the [`onPlatformViewCreated` callback](https://api.flutter.dev/flutter/widgets/HtmlElementView/onPlatformViewCreated.html). In those cases, [a fix like this](https://github.com/flutter/packages/pull/5660) is needed (use the **only [documented way](https://api.flutter.dev/flutter/dart-ui_web/PlatformViewRegistry/getViewById.html)** to obtain the Platform View contents from its `viewId`)

## Issues

Fixes https://github.com/flutter/flutter/issues/137287
Closes https://github.com/flutter/flutter/pull/136548

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-12-21 04:21:23 +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
Harry Terkelsen
20f78ab352 [web:multiview] Only call Renderer.clearFragmentProgramCache on hot restart (flutter/engine#48758)
Previously, we would do this any time a view was disposed, which would
clear ALL fragment programs in the app, not just the ones associated
with the view.

## 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-12-20 11:12:28 -08:00
Michael Goderbauer
dbfad3bfed Sync lints with flutter/flutter (flutter/engine#49192) 2023-12-20 01:12:30 +00:00
Harry Terkelsen
50beeb112d [web] Enforce onDrawFrame/onBeginFrame render rule (flutter/engine#49214)
Also update tests to conform to the render rule.

The render rule is that the call to `render` should only occur in the scope of an `onDrawFrame` or `onBeginFrame` call. As a side effect, this change also fixes a memory leak which occurs in tests using FakeAsync in the `flutter_test` environment (because they don't render anymore).

Fixes https://github.com/flutter/flutter/issues/137073
Fixes https://github.com/flutter/flutter/issues/137669

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-12-19 23:18:10 +00:00
Tong Mu
927fd200ed Revert "Reland 2: Multiview Pipeline (#47239)" (flutter/engine#49238)
This reverts commit 87171e73397f7edfd4c145fbaebdd7208954debf.

Internal performance test shows that this PR negatively affects startup time. I'll reland this PR in parts.

b/307872797

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-12-19 22:30:01 +00:00
Matej Knopp
ad2fe1a759 Convert chromium wheel delta to physical pixels on macOS (flutter/engine#49028)
This has been previously done for Safari in Firefox in
https://github.com/flutter/engine/pull/35428. I'm not entirely sure
since which release, but for past couple of months Chromium seems to be
reporting logical pixels during scroll events as well, which now makes
scrolling on Chrome / macOs 2x slower.

## 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-12-18 22:46:48 +01:00
Bartek Pacia
b87524c6d3 Delete SemanticsUpdateBuilderNew and all references and usages (flutter/engine#49139)
This PR completest the migration by removing `SemanticsUpdateBuilderNew` from the engine.

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` https://github.com/flutter/engine/pull/48882
part 4: [flutter] use (now updated) `SemanticsUpdateBuilder` again https://github.com/flutter/flutter/pull/139942
**part 5: [engine] remove `SemanticsBuilderNew`** <-- we are here
2023-12-18 19:35:58 +00:00
Mouad Debbar
4d71cad1fb [web] Set cursor property on body (flutter/engine#49098)
This is a temporary workaround to get mouse cursor working in multi-view (until https://github.com/flutter/flutter/issues/140226 is resolved).
2023-12-18 15:20:04 +00:00
Matan Lurey
3aae0411b7 Automatically fix header guards in the rest of the flutter/engine repo. (flutter/engine#49059) 2023-12-15 04:11:06 +00:00
LongCatIsLooong
0be3f2d5d6 Fix a bug in the HTML render's getClosestGlyphInfo implementation (flutter/engine#48774)
`closestFragmentAtOffset` takes a horizontal offset from the start of the line, not the start of the paragraph. 

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-12-14 20:57:48 +00:00
Jason Simmons
9538c024ca Reland manual roll of Dart SDK from 82c4571bb2de to a677378ae254 (flutter/engine#49034)
Includes type annotations for JSArray/JSPromise
(see https://dart-review.googlesource.com/c/sdk/+/337923)
2023-12-14 20:01:01 +00:00
Brandon DeRosier
b5725a4a83 [Flutter GPU] Runtime shader import. (flutter/engine#48875)
* Add `--shader-bundle` mode to impellerc that takes a simple JSON spec and produces a single flatbuffer with a pack of named shaders.
* Added "single invocation" mode to the impellerc GN templates.
* Record vertex attribute reflection information.
* Light refactoring of the compiler frontend to make compiler invocations easier to follow.

Example shader bundle spec (json form of the yaml spec as shown in the [Flutter GPU](https://docs.google.com/document/d/1Sh1BAC5c_kkuMVreo7ymBzPoMzb7lamZRPsI7GBXv5M/edit?resourcekey=0-5w8u2V-LS41tCHeoE8bDTQ#heading=h.a3gmnzue7wgq) doc):
```json
{
    "UnlitFragment": {
        "type": "fragment",
        "file": "shaders/flutter_gpu_unlit.frag"
    },
    "UnlitVertex": {
        "type": "vertex",
        "file": "shaders/flutter_gpu_unlit.vert"
    },
    "TextureFragment": {
        "type": "fragment",
        "file": "shaders/flutter_gpu_texture.frag"
    },
    "TextureVertex": {
        "type": "vertex",
        "file": "shaders/flutter_gpu_texture.vert"
    }
}
```

Example impellerc invocation:
```bash
impellerc \
  --include=~/projects/flutter/engine/src/flutter/impeller/compiler/shader_lib \
  --runtime-stage-metal \
  --sl=assets/TestLibrary.shaderbundle \
  --shader-bundle='{"UnlitFragment": {"type": "fragment", "file": "shaders/flutter_gpu_unlit.frag"}, "UnlitVertex": {"type": "vertex", "file": "shaders/flutter_gpu_unlit.vert"}, "TextureFragment": {"type": "fragment", "file": "shaders/flutter_gpu_texture.frag"}, "TextureVertex": {"type": "vertex", "file": "shaders/flutter_gpu_texture.vert"}}'
```

Runtime usage:
```dart
    /// Add a render pass encoder to the command buffer so that we can start
    /// encoding commands.
    final encoder = commandBuffer.createRenderPass(renderTarget);

    /// Load a shader bundle asset.
    final library =
        gpu.ShaderLibrary.fromAsset('assets/TestLibrary.shaderbundle')!;

    /// Create a RenderPipeline using shaders from the asset.
    final vertex = library['TextureVertex']!;
    final fragment = library['TextureFragment']!;
    final pipeline = gpu.gpuContext.createRenderPipeline(vertex, fragment);

    encoder.bindPipeline(pipeline);
```

https://github.com/flutter/engine/assets/919017/6f3e9a59-d180-4ba6-b14c-fa6d7056965c
2023-12-14 00:48:00 +00:00
Victoria Ashworth
1872d4bb32 Allow tests to run on macOS 13 (flutter/engine#48894)
Update macOS web tests to run on macOS 13 and arm64. Changed so test is consistent OS and architecture, which will cause less discrepancy in goldens.

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

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-12-13 19:57:09 +00:00
Jason Simmons
3f4ffc972b Revert Dart SDK back to 3.3.0-219.0.dev (flutter/engine#48990)
See https://github.com/flutter/flutter/issues/140074
See https://github.com/flutter/flutter/issues/140076
2023-12-13 11:34:27 -08:00
LongCatIsLooong
63dabdd2e0 Add a constructor for GlyphInfo. (flutter/engine#48971)
Needed for https://github.com/flutter/flutter/pull/139717

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-12-13 18:01:47 +00:00
Harry Terkelsen
355e113a13 [web:multiview] Make CanvasKitRenderer listen for view creation/disposal events (flutter/engine#48812)
Makes CanvasKitRenderer create and dispose of views by listening to
events from the PlatformViewManager instance.

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

## 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: David Iglesias <ditman@gmail.com>
2023-12-12 16:42:18 -08:00
Jason Simmons
ebd58c3e5d Manual roll of Dart SDK from 82c4571bb2de to a677378ae254 (flutter/engine#48933)
Includes type annotations for JSArray/JSPromise
(see https://dart-review.googlesource.com/c/sdk/+/337923)
2023-12-12 18:34:30 +00:00
Mouad Debbar
f4797dcadf [web] Handle resizes at the view level (flutter/engine#48892)
Currently, in multi-view mode, when the user resizes the window, Flutter views don't respond to the resize. This is because `FlutterViewEmbedder` is the one responding to resize events. But `FlutterViewEmbedder` only works with the implicit view, so multi views didn't respond to resize events.

This PR moves the responsibility of responding to resize events from `FlutterViewEmbedder` to `EngineFlutterView`. Also, tests.

Part of https://github.com/flutter/flutter/issues/134443
2023-12-12 18:02:15 +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
Mouad Debbar
ee266e5318 [web] PointerBinding per view (flutter/engine#48248)
- Move initialization of `PointerBinding`/`KeyboardBinding` out of `FlutterViewEmbedder`.
- `computeEventOffsetToTarget` properly handles events within a given view.
- `PointerBinding` operates on the given Flutter view (it still listens to some `domWindow` events for the implicit view).
    - Stop using globals e.g. `ui.window`, `KeyboardBinding.instance`, `SafariPointerEventWorkaround.instance`, etc.
- `pointer_binding_test.dart` doesn't use globals either.
- `clickDebouncer` is now a static property on `PointerBinding`.

Fixes https://github.com/flutter/flutter/issues/137289
2023-12-11 20:44:58 +00:00
Victoria Ashworth
9622acd973 Fix css changes with macOS 13 and Safari (flutter/engine#48807)
Safari on macOS 13 outputs different styling than before. Adjust tests to accept new changes. 

Fixes https://github.com/flutter/flutter/issues/136274. Fixes https://github.com/flutter/flutter/issues/136279.

Example passing on macOS 12: https://ci.chromium.org/ui/p/flutter/builders/try/Linux%20linux_web_engine/16401/overview
Example passing on macOS 13: https://ci.chromium.org/ui/p/flutter/builders/try/Linux%20linux_web_engine/16396/overview

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-12-11 19:31:25 +00:00
Victoria Ashworth
31210e4a38 Retry when safaridriver fails (flutter/engine#48791)
Starting `safaridriver` is flakey sometimes on macOS 13. It will occasionally error with "Operation not permitted". As a workaround, if it fails with that message, retry starting `safaridriver`.

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

Example of fix on macOS 13 bot: https://ci.chromium.org/ui/p/flutter/builders/try/Mac%20Engine%20Drone/564967/overview
Note: The test is still failing due to https://github.com/flutter/flutter/issues/136279, but you can see it first has error "Operation not permitted" and retries and connects on second attempt.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-12-07 21:55:06 +00:00
Jonah Williams
8b54eb6bf5 [Impeller] Store Buffer/Texture bindings in vector instead of map. (flutter/engine#48719)
Places the binding data in a vector, since they key was only meaningful on metal but not used anywhere. I don't think that we need to specificially handle the case where our own contents bind the same contents multiple times, but interested to discuss if folks disagree.
2023-12-06 19:32:41 +00:00
Jonah Williams
8aeac570ad [Impeller] Prefer moving vertex buffer, place on command instead of binding object. (flutter/engine#48630)
Placing the vertex buffer on the binding object meant that we were actually paying 2x the size cost for it (one for vertex bindings, one for fragment bindings). By moving this object onto command itself, we reduce the size and avoid spliting up the command state in a weird way.

Also updates most of the contents to prefer moving the VertexBuffer.
2023-12-05 21:02:52 +00:00
Jonah Williams
7bad7a0150 [Impeller] Delete tessellation control/eval shader support. (flutter/engine#48649)
We have no plans to ever use these for anything.
2023-12-05 17:11:11 +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
Yegor
d1ed887379 [web] remove ulimit and add -i to felt (flutter/engine#47414)
The ulimit logic has been failing for me for months now and felt still
ran fine. I think we don't need it any more.

Also add the `-i` option for incremental runs of `felt`. It causes felt
to start faster because it doesn't run `pub get`. In the future, we can
also run felt from the snapshot for even faster start-up.
2023-12-01 21:06:49 -08:00
Yegor
15d0ccaa77 [web] Implement multi-view for semantics (flutter/engine#48251)
Implement multi-view for semantics. Main changes:

- `EngineSemanticsOwner` singleton is split into two classes:
- `EngineSemantics` is a singleton that manages global properties of the
semantics tree, such as whether semantics is currently enabled, and what
gesture mode is used.
- `EngineSemanticsOwner` now supports creating multiple instances of the
class. `EngineFlutterView` now points a `EngineSemanticsOwner` that it
owns.
- Fix a number of issues with disposal logic. Now that views can come in
and out disposal has to be more robust than previously.
`EngineSemanticsOwner` acquired a `reset()` and `SemanticsObject` acquired
 a `dispose()` that clean up the tree and individual nodes respectively.
- In particular, this fixes an issue in Skwasm mode where slight
differences in asynchrony caused the semantics test to fail because old
nodes continued firing events after they were removed from the document
due to improper disposal.
2023-12-01 11:10:05 -08:00
Harry Terkelsen
0bac7851a8 [canvaskit] Add ImageFilter.compose (flutter/engine#48546)
Adds ImageFilter.compose support in CanvasKit. Previously this would
crash.

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

## 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-11-30 16:37:07 -08:00
Harry Terkelsen
9b26cdc88c [canvaskit] Revert to drawImage rendering on Chrome 110 or earlier (flutter/engine#48515)
This updates a fix for Chrome 110 and earlier to always activate, not
just on Windows.

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

## 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-11-30 12:41:23 -08:00
Mouad Debbar
ac83bcf45e [web] No implicit view in multi-view mode (flutter/engine#48505)
- No implicit view in mult-view mode.
- `window.devicePixelRatio` => `EngineFlutterDisplay.instance.devicePixelRatio`.
- `window.physicalSize` => `view.physicalSize`.
- Remove `LayerTree.frameSize`.
- `defaultRouteName` is set to `/` when there's no implicit view.
- All routing operations are noops in multi-view mode.

With these changes, I was able to run all examples in https://github.com/goderbauer/mvp without an implicit view.
2023-11-29 21:11:05 +00:00
Harry Terkelsen
f377fc827e [canvaskit] Disable createImageBitmap support on Chrome 110 or older on Windows. (flutter/engine#48475)
On Chrome 110 or older, there is a bug where an ImageBitmap will be read back upside down if it is stored upside down on the GPU. This only happens on Windows. So if we are on Windows and running on Chrome 110 or older, then fall back to `drawImage` based rendering.

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

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-11-29 18:06:11 +00:00
Jason Simmons
c0ea0d4a0e Remove use of variable length arrays (flutter/engine#48232)
The variable length array extension will be disabled by default in the next roll of Clang.
2023-11-28 21:28:07 +00:00
Kevin Lubick
92bce6db0e Replace all calls to SkTypeface::Make with SkFontMgr ones (flutter/engine#48319)
Similar to https://github.com/flutter/engine/pull/48179, Flutter needs
to stop depending on the default font manager, which the
`SkTypeface::Make*` calls do implicitly

## 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-11-28 07:08:35 -05:00
Harry Terkelsen
e3d0abe659 [canvaskit] Fall back to drawImage for browsers that don't support createImageBitmap (flutter/engine#48336)
Safari 14 doesn't have the `createImageBitmap` API available. This
change allows us to render into `RenderCanvas` without using
`createImageBitmap` in that case.

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

## 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-11-27 16:23:24 -08:00
Jim Graham
1f0d7cd7ea SurfaceFrame root DisplayLists will no longer prepare an RTree (flutter/engine#48422)
The root slice of a surface frame was requesting the construction of an RTree from its DisplayList when it was built from a layer tree, but since the layer tree already does branch culling, it would not benefit from any further culling during `DisplayList::Dispatch`. Further, if there are platform views present in the layer tree then they will need an RTree to accurately convey "pixel ownership" information to the platform, but the root slice lives below any and all platform views, so it is the only slice that doesn't need an RTree for that case.

The cost of having an RTree in that slice was the accumulation of information and lists of rects that would never prove useful.
2023-11-27 23:27:34 +00:00
Michael Goderbauer
136f4a03c4 Dynamic view sizing [dart:ui] (flutter/engine#48090)
Towards https://github.com/flutter/flutter/issues/134501.

This PR makes the following changes to the public dart:ui API:

* It adds the `FlutterView.pysicalConstraints` property that describes max and min width and height for a view. The framework is allowed to size the `FlutterView` to any `Size` that meets these constraints.
* It adds an optional `size` argument to `FlutterView.render`. The framework provides the chosen `Size` that meets the aforementioned constraints to the `render` method. If the `FlutterView.pysicalConstraints` are tight (minHeight == maxHeight and minWidth == maxWidth) the argument is optional to remain backwards compatible. In all other cases, a `Size` must be provided.
* It adds a `ViewConstraints` class, which is basically the `dart:ui` version of `BoxConstraints` (This is similar to how we have `ViewPadding` in dart:ui to mirror `EdgeInsets` from the framework). It describes the constraints of a `FlutterView`, i.e. it powers the `FlutterView.pysicalConstraints` property.

This change does not wire anything up to the embedders. For now, `FlutterView.pysicalConstraints` just returns tight constraints for the embedder-provided size of the view (`FlutterView.physicalSize`) and the size provided to `FlutterView.render` is ignored (after it is checked that it meets the constrains). 

This PR enables the framework to implement the new dynamic view sizing and embedders to separately expose the new functionality to their clients.

Presubmits will fail until https://github.com/flutter/flutter/pull/138565 is submitted to the framework.

**DO NOT SUBMIT until https://github.com/flutter/flutter/pull/138648 is ready.**
2023-11-27 22:33:59 +00:00
Harry Terkelsen
0e82e66bdd [canvaskit] Enable multiview rendering (flutter/engine#48301)
Allows the CanvasKitRenderer to render into multiple views.

## 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: skia-flutter-autoroll <skia-flutter-autoroll@skia.org>
Co-authored-by: Mouad Debbar <mdebbar@google.com>
Co-authored-by: 林洵锋 <linxunfeng@yeah.net>
Co-authored-by: Brandon DeRosier <bdero@google.com>
Co-authored-by: Jonah Williams <jonahwilliams@google.com>
Co-authored-by: Matej Knopp <matej.knopp@gmail.com>
2023-11-27 12:59:26 -08:00
Brandon DeRosier
c49cfdc9a9 [Flutter GPU] Texture binding, index binding, attachments, depth state. (flutter/engine#48386)
Now rendering textured 3D models!

* Combined depth+stencil attachment.
* Allow for multiple color attachments.
* Add blend mode configuration.
* Fix uniform ordering for vertex shaders.
* Texture binding and sampling options.
* Index buffer binding.
* Depth configuration.
2023-11-26 19:47:16 -08:00
Brandon DeRosier
05f43a96aa [Flutter GPU] Raster encoding. First triangle! (flutter/engine#48314)
First triangle, in the framework! 🎉 

Adds shader libraries, pipelines, command buffers, render passes, etc.

* Light pipelines/shader objects. No optimization yet, pipeline warming
to come.
* "Dynamic" command style. Don't re-send bindings if you don't need to.
Essentially: https://github.com/flutter/flutter/issues/133179
* No need to explicitly encode passes.
* Minimal descriptor usage.
* Nothing is async, except for the optional command buffer completion
callback.

It took a bunch of experimenting to get here, but I think things are
starting to look pretty neat. :)

Todo:
* Land the shader bundle format/remove the testing hacks & fixtures that
piggyback off of the runtime effect system.
* Add remaining calls for blend config, clearing bindings, etc.
* Inconsistent error handling patterns that need cleanup.
* Maybe: Surface exceptions for validation errors.
* Handle the texture usage bitmask more elegantly.
2023-11-24 19:02:58 -08:00
Mouad Debbar
4c20a233a8 [web] Hook the new JS API to the FlutterViewManager (flutter/engine#48283)
- Auto-generate view IDs.
- Views don't auto-register/auto-unregister anymore.
- Remove `EnginePlatformDispatcher.registerView/unregisterView` methods.
- Add `FlutterViewManager.createAndRegisterView/disposeAndUnregisterView/dispose` methods.
- Hook the `addView`/`removeView` JS APIs to `FlutterViewManager`.
2023-11-22 21:27:56 +00:00
LongCatIsLooong
59a5579465 Expose a few more glyph apis from ui.Paragraph (flutter/engine#47698)
Add 2 methods for querying glyph-related metrics

```dart
  GlyphInfo? getClosestGlyphInfoForOffset(Offset offset); 
  GlyphInfo? getGlyphInfoAt(int codeUnitOffset);
```

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