3404 Commits

Author SHA1 Message Date
Tong Mu
c5e0858a01 Add scheduleWarmUpFrame (flutter/engine#50570)
This PR adds `PlatformDispatcher.scheduleWarmUpFrame`.

This PR is needed for the follow up changes:
* The framework will switch to using this function to render warmup
frames in https://github.com/flutter/flutter/pull/143290.
* Then the engine will finally be able to switch to multiview pipeline
with no regression on startup timing in
https://github.com/flutter/engine/pull/49950.

For why the warm up frame must involve the engine to render, see
https://github.com/flutter/flutter/issues/142851.


## Pre-launch Checklist

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

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

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[test-exempt]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[C++, Objective-C, Java style guides]:
https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
[testing the engine]:
https://github.com/flutter/flutter/wiki/Testing-the-engine
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
2024-02-21 16:46:11 -08:00
Juanjo Tugores
e9cfdd0277 Make the view focus binding report focus transitions across elements. (flutter/engine#50610)
Make the view focus binding report focus transitions across elements.

Previously the web engine reported all the focusin/focusout events as if the elements were first blurred before moving the focus.

Relevant Issues are:

* Design doc: https://flutter.dev/go/focus-management 
* Focus in web multiview: https://github.com/flutter/flutter/issues/137443
* Platform dispatcher changes: https://github.com/flutter/engine/pull/49841

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-02-21 23:02:58 +00:00
Zachary Anderson
f6629ffe5c Use 'et format' in CI. Check formatting of all files in CI (flutter/engine#50810)
This PR changes the format check on CI to use the command added in
https://github.com/flutter/engine/pull/50747.

Additionally, while making this change, I noticed that the CI check was
not checking the formatting of all files, and that as a result, files
were present in the repo with incorrect formatting. I have fixed the
formatting and fixed the check to always check all files.
2024-02-21 09:38:08 -08:00
Bruno Leroux
5e5052b8f9 [Web] Update modifier state when Meta key is seen as Process key (flutter/engine#50779)
## Description

On Web, browsers can emit key events with a logical key sets to `Process` when the physical key is MetaLeft. Because the modifier state is 0 despite Meta key being pressed this will trigger an assert.
This PR adds some logic for this specific case. Maybe a more slightly broader solution will be needed (using the same logic for all modifiers ?). I focused on MetaLeft because it was directly reported on  https://github.com/flutter/flutter/issues/141186.

## Related Issue

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

## Tests

Adds 1 test.
2024-02-21 05:37:08 +00:00
Brandon DeRosier
21bb5f4bda [Flutter GPU] Fix symbol export for windows. (flutter/engine#50755)
Symbols weren't getting exported on Windows because the `FML_OS_WIN`
macro wasn't being imported.
2024-02-20 19:03:27 -08:00
Jonah Williams
3447737d89 [Impeller] more nullchecks in image decoder. (flutter/engine#50787)
Speculative fix for https://github.com/flutter/flutter/issues/138897 which cannot be reprouced.
2024-02-20 22:19:55 +00:00
Jackson Gardner
b8d198edc2 Temporarily disable goldens for Safari. (flutter/engine#50724)
Safari is producing too many golden diffs. See https://github.com/flutter/flutter/issues/143591. This disables them for now to stop the noise, but we should look into a longer term solution.
2024-02-16 21:14:10 +00:00
Martin Kustermann
0e6ffa7346 [web] Remove unused allowInterop usage in flutter web code (flutter/engine#50718)
The CLs that migrated to static interop forgot to update the
corresponding comments regarding the need to use `allowInterop`.

The re-exported `allowInterop` function happened in an internal library
(not exposed via `dart:ui*`) and was unused.

Issue https://github.com/dart-lang/sdk/issues/54908
2024-02-16 21:46:42 +01:00
Michael Goderbauer
da30adfc6f Fix implementation imports outside of lib (flutter/engine#50727)
Work towards https://github.com/dart-lang/linter/issues/4859

There are libraries outside a `lib/` directory, which violate `implementation_imports`.
2024-02-16 20:19:33 +00:00
Bruno Leroux
4b5c993fe4 [Web] Ignore invalid keyboard events related to autofill (flutter/engine#50590)
## Description

This PR fixes an 'Unexpected null value' error related to autoFill.
When using Autofill feature, Chrome emits keyboard events whose `event.code` and `event.key` are null.

## Related Issue

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

## Tests

Adds 1 test.
2024-02-16 07:04:48 +00:00
Juanjo Tugores
ec948a8b48 Move the accesibility placeholder to the platform dispatcher. (flutter/engine#50608)
Move the accesibility placeholder to the platform dispatcher.

This change makes the platform dispatcher append a single accesibility placeholder, per app, to the `<body />`. Previous behavior was to insert a placeholder inside each `<flutter-view />`

Relevant Issues are:

* Design doc: https://flutter.dev/go/focus-management 
* Focus in web multiview: https://github.com/flutter/flutter/issues/137443
* Platform dispatcher changes: https://github.com/flutter/engine/pull/49841

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-02-15 22:07:58 +00:00
Renan
918d73b4aa fix: consider array size on canvaskit shader data (flutter/engine#49754)
This PR changes the ShaderData construction on canvaskit to consider array uniforms. 

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

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

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-02-15 15:23:12 +00:00
Chinmay Garde
6c17d7bf9d Use a GN variable (dart_src) to reference the location of the Dart checkout. (flutter/engine#50624)
Towards https://github.com/flutter/flutter/issues/143335
2024-02-14 21:12:23 -08:00
David Iglesias
45adab9726 [web] Add dynamic view sizing (v2) (flutter/engine#50271)
### Changes

* Introduces a new `viewConstraints` JS configuration parameter to configure max/min width/height constraints for a view. Those can have the following values:
  * An integer `>= 0`: max/min size in pixels
  * `Infinity` (or `Number.POSITIVE_INFINITY`): (only for max values) -> **unconstrained**.
  * When any value is not set, it defaults to "tight to the current size".
    * See [Understanding constraints](https://docs.flutter.dev/ui/layout/constraints).
* Computes the correct `physicalConstraints` of a view off of its `physicalSize` and its `viewConstraints` for the framework to use during layout.
  * When no constraints are passed, the current behavior is preserved: the default constraints are "tight" to the `physicalSize`.
* Resizes the current view DOM when requested by the framework and updates its internal physicalSize, then continues with the render procedure.

### Example

This is how we can configure a view to "take as much vertical space as needed":

```js
flutterApp.addView({
  viewConstraints: {
    minHeight: 0,
    maxHeight: Infinity,
  },
  hostElement: ...,
});
```

### TODO

* Needs actual unit tests

### Issues

* Fixes https://github.com/flutter/flutter/issues/137444
* Closes https://github.com/flutter/engine/pull/48541

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-02-15 00:56:57 +00:00
LongCatIsLooong
cd637f73f2 Temporarily change canvaskit kitchensink test to unblock the skia roll (flutter/engine#50617)
The previous skia roll (https://github.com/flutter/engine/pull/50609) failed on [Linux linux_web_engine](https://ci.chromium.org/b/8756177705618610401).
I've tested that the failing `canvaskit_api_tt_on_test.dart` would pass with the new skia revision `'a1c58c4eb6d5ae553097c5d27c134e09c8825e06` on this patch.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-02-14 00:27:50 +00:00
Matan Lurey
154fa183ad Make dart:ui#Paint final to allow changes/disallow implementing. (flutter/engine#50557)
Closes https://github.com/flutter/flutter/issues/142937.
2024-02-12 15:30:32 -08:00
Juanjo Tugores
10c9a2a71a Rename [ViewFocusDirection.backwards] to [ViewFocusDirection.backward] (flutter/engine#50533)
Rename [ViewFocusDirection.backwards] to [ViewFocusDirection.backward]

Relevant Issues are:

Design doc link: https://github.com/flutter/website/actions/runs/7560898849/job/20588395967
Design doc: https://github.com/flutter/flutter/issues/141711
Focus in web multiview: https://github.com/flutter/flutter/issues/137443
Platform dispatcher changes: https://github.com/flutter/engine/pull/49841

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-02-12 17:24:05 +00:00
Matan Lurey
748e3f8e0b Remove legacy references to Cirrus and suspected dead-code. (flutter/engine#50442) 2024-02-10 22:08:23 +00:00
Juanjo Tugores
7b2766a191 Make the web engine publish view forward focus and unfocus events (flutter/engine#50177)
Make the flutter web engine publish view focus events.

Relevant Issues are:
* Design doc link: https://github.com/flutter/website/actions/runs/7560898849/job/20588395967
* Design doc: https://github.com/flutter/flutter/issues/141711
* Focus in web multiview: https://github.com/flutter/flutter/issues/137443
* Platform dispatcher changes: https://github.com/flutter/engine/pull/49841

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-02-09 23:30:16 +00:00
David Iglesias
8a8ce3b20f [web] Fix HtmlViewEmbedder.dispose (flutter/engine#50482)
Fix a `Concurrent modification during iteration` in the `dispose` method of the HtmlViewEmbedder.

### Issues

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

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-02-09 19:11:48 +00:00
David Iglesias
4b7ef33126 Reland "[web] Fix Scene clip bounds. Trigger resize on DPR Change." (flutter/engine#50457)
## Changes

1. Reverts commit 911b1400ea, to re-land:
   * https://github.com/flutter/engine/pull/50161
2. Adds a fix to the way the HTML Scene computes its bounds that should be compatible with the current imlementation of Flutter's Golden tests.

## Issues

* Fixes https://github.com/flutter/flutter/issues/129182

## Testing

### Goldens

Verified locally that all the golden tests that caused this to roll back looked acceptable:

* [💾 goldens-check.zip](https://github.com/flutter/engine/files/14203071/goldens-check.zip)

### Test app

* Redeployed at:
  * https://dit-astral-test.web.app/?renderer=html (HTML, full screen)
  * https://dit-astral-test.web.app/?renderer=html&embedded=true (CK, embedded) 
  * https://dit-astral-test.web.app/?renderer=canvaskit (CK, full screen)
  * https://dit-astral-test.web.app/?renderer=canvaskit&embedded=true (CK, embedded) 

## Next steps

During the investigation of this rollback, we found some opportunities to improve our web tests in the repo. Tracking issue:

* https://github.com/flutter/flutter/issues/143124

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-02-08 23:35:04 +00:00
Hassan Toor
650f4b9728 [web] - Fix inputmode on Android Firefox (flutter/engine#46901)
The wrong keyboard type shows when users specify the phone input type in the framework. 

This is happening because:

* We usually set `inputmode` for mobile text editing strategies.
* We only use Android's text editing strategy for Blink browser engines (not firefox), so we fall through to the Firefox text editing strategy which I believe should only be used for desktop firefox.
* So we're ending up in a case where Android + Firefox doesn't set the inputmode and it pops open the default alphanumeric keyboard

Fixes https://github.com/flutter/flutter/issues/136351
2024-02-08 20:10:48 +00:00
ᠵᠠᠭᠠᠨᠵᠠᠪ ᠪᠤᠷᠵᠢᠭᠤᠳ ᠰᠠᠴᠤᠷᠠᠭ
af574f2aae Fix: On the Web, cannot support multiline inputting when registering customized TextInputControl (flutter/engine#45522)
For [flutter/flutter/125875](https://github.com/flutter/flutter/issues/125875)

When registering customized TextInputControl, the _PlatformTextInputControl sends inputType = TextInputType.none to the engine. After receiving TextInputType.none, the engine on the Web will create a `<input>` element instead of  `<textarea>`. So there is no way to input \n(multiline).

This is my solution. I tested in Android Chrome, iOS Safari, and macOS Chrome. It works for me. But I'm not sure about other use cases. I pleasure, If someone gives me suggestions.
2024-02-07 15:15:00 +00:00
Ian Hickson
05e5a97357 Provide toStrings for Native objects (flutter/engine#50168)
This hides the "Instance of _Native" bit that you get in debug output otherwise.
2024-02-06 22:39:00 +00:00
Matan Lurey
4ed520b2af Skip flaking test on Windows nobody is fixing. (flutter/engine#50401)
Filed https://github.com/flutter/flutter/issues/142991 to re-enable.
2024-02-06 10:23:06 -08:00
auto-submit[bot]
911b1400ea Reverts "[web] Fix Scene clip bounds. Trigger resize on DPR Change." (flutter/engine#50404)
Reverts flutter/engine#50161

Initiated by: jonahwilliams

Reason for reverting: This is causing what looks like bogus goldens on the framework -> engine roll: https://github.com/flutter/flutter/pull/142966

Original PR Author: ditman

Reviewed By: {yjbanov, mdebbar}

This change reverts the following previous change:
Original Description:
The Scene of the HTML renderer is passing incorrect size information to the engine, and when DPR<1, it can result in elements being culled off of the viewport.

In addition to that, when an app is embedded, not all changes in DPR cause a Resize event (only those some of the dimensions fails by a rounding error!), so this PR ensures that all DPR events in embedded trigger a resize event.

### Issues

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

### Testing

Looking good at: https://dit-astral-test.web.app

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-02-06 17:35:47 +00:00
David Iglesias
76129ffb8f [web] Fix Scene clip bounds. Trigger resize on DPR Change. (flutter/engine#50161)
The Scene of the HTML renderer is passing incorrect size information to the engine, and when DPR<1, it can result in elements being culled off of the viewport.

In addition to that, when an app is embedded, not all changes in DPR cause a Resize event (only those some of the dimensions fails by a rounding error!), so this PR ensures that all DPR events in embedded trigger a resize event.

### Issues

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

### Testing

Looking good at: https://dit-astral-test.web.app

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-02-06 01:48:00 +00:00
Juanjo Tugores
358d8b6229 Add the focus state related methods to the platform dispatcher (flutter/engine#50273)
These changes were originally landed on
https://github.com/flutter/engine/pull/49841 but reverted in
64fe7b86c3.
I fixed the offending dart snippets and (think) they now will work
without issues (I think I was able to verify them locally by manually
patching my bin/cache/... copy of these files with these changes).

Relevant Issues are:
* Design doc link:
https://github.com/flutter/website/actions/runs/7560898849/job/20588395967
* Design doc: https://github.com/flutter/flutter/issues/141711
* Focus in web multiview:
https://github.com/flutter/flutter/issues/137443

## Pre-launch Checklist

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

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

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[test-exempt]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[C++, Objective-C, Java style guides]:
https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
[testing the engine]:
https://github.com/flutter/flutter/wiki/Testing-the-engine
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
2024-02-02 10:13:00 -08:00
auto-submit[bot]
64fe7b86c3 Reverts "Add the focus state related methods to the platform dispatcher" (flutter/engine#50268)
Reverts flutter/engine#49841
Initiated by: zanderso
This change reverts the following previous change:
Original Description:
This change augments the platform dispatcher to allow the engine <===> framework to communicate flutter and platform focus changes.

Relevant Issues are:
* Design doc link: https://github.com/flutter/website/actions/runs/7560898849/job/20588395967
* Design doc: https://github.com/flutter/flutter/issues/141711
* Focus in web multiview: https://github.com/flutter/flutter/issues/137443

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-02-02 02:59:26 +00:00
Tong Mu
be6209e136 Remove number of arguments from defining Dart FFI (flutter/engine#50153)
The number of arguments are not used. 

And also, even if we need it in the future, they can be derived at compile time:

```cpp
template <typename T>
struct function_traits;

template <typename Ret, typename... Args>
struct function_traits<Ret(Args...)>
{
    using params = std::tuple<Args...>;
};

template <typename T>
constexpr std::size_t get_parameter_count() {
    return std::tuple_size<typename function_traits<T>::params>::value;
}

template <typename T>
struct member_function_traits;

template <typename C, typename Ret, typename... Args>
struct member_function_traits<Ret(C::*)(Args...)>
{
    using params = std::tuple<Args...>;
};

template <typename T>
constexpr std::size_t get_member_function_parameter_count() {
    return std::tuple_size<typename member_function_traits<T>::params>::value;
}

```

(I got the code above with ChatGPT but I verified that they work)

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-02-01 23:58:31 +00:00
Juanjo Tugores
9858aa35c2 Add the focus state related methods to the platform dispatcher (flutter/engine#49841)
This change augments the platform dispatcher to allow the engine <===>
framework to communicate flutter and platform focus changes.

Relevant Issues are:
* Design doc link:
https://github.com/flutter/website/actions/runs/7560898849/job/20588395967
* Design doc: https://github.com/flutter/flutter/issues/141711
* Focus in web multiview:
https://github.com/flutter/flutter/issues/137443

## Pre-launch Checklist

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

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

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[test-exempt]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[C++, Objective-C, Java style guides]:
https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
[testing the engine]:
https://github.com/flutter/flutter/wiki/Testing-the-engine
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
2024-02-01 13:20:30 -08:00
auto-submit[bot]
90b6db8915 Reverts "Remove migration flag and unused header files" (flutter/engine#50229)
Reverts flutter/engine#50216
Initiated by: zanderso
This change reverts the following previous change:
Original Description:
The `applyRoundingHack` flag is no longer used by the framework. This also removes the [lib/ui/text/line_metrics.h](https://github.com/flutter/engine/pull/50216/files#diff-9175619f2b114dffef67eba38511b34afe6abefd4f697f4758647133895b34f5) file which doesn't seem to be referenced anywhere.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-02-01 03:47:16 +00:00
Tong Mu
f1b651bfd0 Multiview: Add view ID to _render and remove render rule skipping (flutter/engine#50220)
This PR adds a view ID parameter to the Dart FFI `_render` function, and
also remove the logic that skips illegal renders that violates the
render rule.

I decided to implement the change to add the view ID as a separate PR
because it's blocking us from performing benchmark testing internally,
which is required to verify before merging the full multiview pipeline.

We're also abolishing the render rule for now to allow presenting the
warmup frame, which affects the startup performance. It is planned to
implement the render rule once we can coordinate the warmup frame into
the pipeline.

### More on removing the render rule enforcement

The project needs to be divided into two phases:
* Phase 1: Dart:ui doesn't kip out-of-vsync frames. And the pipeline
presents these frames in a hacky way.
* Phase 2: Dart:ui skip out-of-vsync frames, but submit warmup frames
using a dedicated method. The pipeline contains no hacks.

The current logic only enforces the render rule in debug mode. It's not
desired to have the debug mode and the release mode behaving
differently. Moreover, I'd like to make only the necessary changes for
phase 1, so that there is as little "to be used in the future" code
between the two phases as possible.

## Pre-launch Checklist

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

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

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[test-exempt]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[C++, Objective-C, Java style guides]:
https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
[testing the engine]:
https://github.com/flutter/flutter/wiki/Testing-the-engine
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
2024-01-31 16:38:07 -08:00
LongCatIsLooong
737437f718 Remove migration flag and unused header files (flutter/engine#50216)
The `applyRoundingHack` flag is no longer used by the framework. This also removes the [lib/ui/text/line_metrics.h](https://github.com/flutter/engine/pull/50216/files#diff-9175619f2b114dffef67eba38511b34afe6abefd4f697f4758647133895b34f5) file which doesn't seem to be referenced anywhere.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-02-01 00:36:16 +00:00
Ashish Myles
1ee98ba880 Make screen reader announcement append a non-breaking space every other message. (flutter/engine#50151)
This fixes an issue when the same message was sent to the screen reader
again and was not subsequently announced by VoiceOver despite the prior
message having long been removed from the DOM.

Fixes https://github.com/flutter/flutter/issues/142250
2024-01-31 17:30:15 -05:00
Harry Terkelsen
2db9940615 [CanvasKit] Only render one frame at a time. (flutter/engine#50055)
Only have one additional queued frame. If more than one frame is
requested while the current frame is rendering, only the last frame is
queued.

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

## Pre-launch Checklist

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

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

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[test-exempt]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[C++, Objective-C, Java style guides]:
https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
[testing the engine]:
https://github.com/flutter/flutter/wiki/Testing-the-engine
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
2024-01-31 14:00:08 -08:00
Mouad Debbar
266c32239f [web] Final nail in FlutterViewEmbedder's coffin (flutter/engine#49769)
- Extracted `ResourceManager` out of `FlutterViewEmbedder`.
- Extracted `GlobalHtmlAttributes` out of `FlutterViewEmbedder`.
- Removed usages of:
    - `FlutterViewEmbedder.reset()`.
    - `flutterViewEmbedder`.
    - `ensureFlutterViewEmbedderInitialized`.
- Deleted `FlutterViewEmbedder`.

Fixes https://github.com/flutter/flutter/issues/134443
2024-01-31 17:22:44 +00:00
Jonah Williams
1cd141f1a1 [Impeller] Reland: add interface for submitting multiple command buffers at once. (flutter/engine#50180)
Reland of:  https://github.com/flutter/engine/pull/50139

Metal does not seem to like it when we collect 50+ command buffers at once. Adjust the aiks context logic to regularly flush the cmd buffers.
2024-01-30 21:21:48 +00:00
auto-submit[bot]
f3e4437823 Reverts "[Impeller] Add interface for submitting multiple command buffers at once." (flutter/engine#50174)
Reverts flutter/engine#50139
Initiated by: jonahwilliams
This change reverts the following previous change:
Original Description:
The Impeller Vulkan backend benefits from batching submission to the vk graphics queue. Managing this automatically is non-trivial and adds surprising/fragile thread based behavior, see: https://github.com/flutter/engine/pull/49870

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

TLDR

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

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

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

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

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

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

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

TLDR

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

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

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

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

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

Fixes https://github.com/flutter/flutter/issues/141123
2024-01-30 07:48:35 +00:00
David Iglesias
d9ef3e2551 [web] Do not wipe the PlatformViewManager when disposing of a view. (flutter/engine#49991)
When a view gets disposed of, its rasterizer completely clears up the singleton `PlatformViewManager`. Particularly, it removes all registered platform view factories.

This is wrong because the remaining PlatformViews on the page cannot be re-rendered, and the default Platform View factories (used by `pointer_interceptor`, for example), disappear.

This PR attempts to preserve the `dispose` logic of the canvaskit rasterizer, without using the `debugClear` method of the `PlatformViewManager` (which is supposedly test-only).

## Issues

* Fixes https://github.com/flutter/flutter/issues/142094

## Tests

* Added unit-test
* Deployed demo app: https://dit-maps-tests.web.app

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-01-26 20:23:26 +00:00
Matan Lurey
e9e5a237f8 Finish landing missing/incorrect header guards across flutter/engine (flutter/engine#50069)
Generated by https://github.com/flutter/engine/pull/48903 (`dart ./tools/header_guard_check/bin/main.dart --fix`).

As discussed with @cbracken and @jmagman, the guards are not technically needed on the Mac/iOS code, but they (a) do not hurt and (b) still provide value if for some reason `#include` is used instead of `#import` (though I suspect we could try to add that to the tool in the future as well).
2024-01-26 19:42:36 +00:00
David Iglesias
9cc9f396b5 [web] Add views proxy and getInitialData. (flutter/engine#49320)
Adds a Dart API so Application/Plugin programmers can retrieve the `initialData` configuration value that may be passed when adding a view from JS in a multiViewEnabled app.

When adding a view to an app like this:

```js
flutterApp.addView({
  hostElement: someElement,
  initialData: {
    randomUUID: globalThis.crypto.randomUUID(),
  }
});
```

`initialData` can be accessed from Dart by defining a JS-interop class like:

```dart
import 'dart:js_interop';

// The JS-interop definition of the `initialData` object passed to the views of this app.
@JS()
@staticInterop
class InitialData {}

/// The attributes of the [InitialData] object.
extension InitialDataExtension on InitialData {
  external String? get randomUUID;
}
```

And then, from the code of the application:

```dart
...
  Widget build(BuildContext context) {
    final int viewId = View.of(context).viewId;
    final InitialData? data = ui_web.views.getInitialData(viewId) as InitialData?;
    return Text('${data?.randomUUID}');
  }
...
```

## Testing

Will add unit tests once naming is sorted out :)

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-01-26 02:36:37 +00:00
David Iglesias
4292cddf6f [web] Prevent re-rendering disposed views when the engine hot restarts. (flutter/engine#49958)
While debugging a different [issue](https://github.com/flutter/flutter/issues/141588), @elliette identified a problem with the web engine when a flutter web app hot-restarts.

TL;DR: the engine is requesting the framework to re-render a view as it tears them down, causing an assertion failure.

This fix stops listening to changes on view "disposed" events when the engine itself is being disposed, so it doesn't trigger re-renders for views that are never coming back.

## Issues

* Fixes https://github.com/flutter/flutter/issues/142030

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-01-26 02:26:21 +00:00
Bruno Leroux
282cb244ad Fix a typo in ChannelBuffers documentation (flutter/engine#49928)
Fix one typo in ChannelBuffers documentation
2024-01-25 21:17:17 +00:00
maRci002
e0a9cc7ce0 [web] add support for AppLifecycleState changes (flutter/engine#44720)
closes flutter/flutter#53107

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

**PR includes:**

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

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-01-25 16:31:12 +00:00
Jonah Williams
31a5d5d5c9 [Impeller] use const std::unique_ptr ref for Sampler type. (flutter/engine#49974)
The backend specific sampler libraries hold a strong reference to the native sampler objects and never clear this cache. As a result of this, we don't theoretically need rendering commands to increment a shared_ptr ref count - instead the sampler library can provide the Sampler object as a const ref and guarantee that it continues to be valid.

This allows us to reduce the amount of refcount ops for commands that use samplers.

Additionally, the sampler library uses nullptr as a sentinel for failing to construct a sampler object. Since sampler already has an isValid member that is checked - we can replace this with a specific invalid object subtype.
2024-01-24 18:14:42 +00:00
Jonah Williams
6f0249a062 [ui] hold a strong reference to fragment program objects. (flutter/engine#49868)
The native engine needs to hold a strong reference to fragment programs. So the dart side holding a weak ref is more or less pointless
2024-01-24 00:08:24 +00:00
Bruno Leroux
2538fd2edb [Web] Fix an assertion error due to synthesized keyboard events (flutter/engine#49087)
## Description

On Web, browsers can emit key events with a logical key sets to `Process` during compostion.
It is usually not a problem, but in some edge cases (for instance when the browser window lost focus and some keys events were missed), the Flutter web engine might synthesize an up event with a logical key value different that the one used for the down event and this will lead to an assertion message on the framework side.

## Related Issue

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

## Tests

Adds 1 test.
2024-01-23 20:26:12 +00:00
Mouad Debbar
22a1d5c7d7 [web] Bootstrap tests without implicit view by default (flutter/engine#48629)
- Follow up tests for https://github.com/flutter/engine/pull/48505
    - Tests for navigation without an implicit view should work.
- Package [this workaround](6efee0e79b/lib/web_ui/test/engine/semantics/semantics_multi_view_test.dart (L29-L30)) behind a nice, future-proof API.
- Tests by default start with no implicit view.
    - Tests that need an implicit view have to explicitly indicate so (by using the `withImplicitView` param).

Fixes https://github.com/flutter/flutter/issues/138906
2024-01-22 20:43:50 +00:00