3534 Commits

Author SHA1 Message Date
Yegor
17f50b3a8a [semantics] fix dartdoc grammar (flutter/engine#53121)
Courtesy of @gspencergoog: "which widget" is korrecter than "what widget".
2024-05-30 22:22:19 +00:00
Yegor
d3b6b1be14 add SemanticsAction.focus (flutter/engine#53094)
Add `SemanticsAction.focus`. This PR just adds the new enum value without any logic. Adding the enum value first to unblock work that needs to be done on both the engine and framework side that will actually implement all the necessary logic.

This is PR 1 out of ~3 for https://github.com/flutter/flutter/issues/83809
2024-05-30 17:15:53 +00:00
Brandon DeRosier
4a98184140 [Flutter GPU] Upload flutter_gpu.zip upon successful completion of ci/android_debug. (flutter/engine#53107)
Part of https://github.com/flutter/flutter/issues/131711.

Also, stops distributing `flutter_gpu` as part of the host artifacts, since it's not target-specific.

This enables us to use the same distribution mechanism as the `sky_engine` package.

Corresponding framework PR: https://github.com/flutter/flutter/pull/149299
2024-05-30 16:08:44 +00:00
Kaylee Lubick
a4db5f1ce4 Replace several calls to GrGLMakeNativeInterface with more direct APIs (flutter/engine#53064)
We are restructuring Skia and plan to remove GrGLMakeNativeInterface at
some point. This updates as many places as possible to use the direct
and explicit instantiation instead of having "Skia guess". This should
ideally not be changing behavior - if it does, then the PR should be
modified.

## 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
2024-05-30 08:14:53 -04:00
Jonah Williams
0847b349a7 [Impeller] revert changes to IO thread upload scheduling. (flutter/engine#53096)
Fixes https://github.com/flutter/flutter/issues/147429

Turns out we need the I/O thread for all backends still to limit uploads otherwise we compete with the raster thread.
2024-05-29 20:59:16 +00:00
Michael Goderbauer
c7f659ac91 Switch to FilterQuality.medium for images (flutter/engine#52984)
https://github.com/flutter/flutter/issues/148253
2024-05-29 20:02:17 +00:00
johnniwinther
43149fdc24 Remove use of --nnbd-agnostic (flutter/engine#53055)
The Dart VM no longer supports unsound null safety, so we don't need to
generate the platform in agnostic mode.
2024-05-28 10:07:40 +02:00
Harry Terkelsen
1f57178c37 [canvaskit] Fix overlay reorganization for edge case with only 1 overlay (flutter/engine#53006)
When there is only 1 overlay, move pictures in the reduced rendering to the last canvas instead of the second-to-last.

Fixes a bug in https://github.com/flutter/engine/pull/51397

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-05-24 18:00:06 +00:00
LongCatIsLooong
35ca2dd175 Allow unsetting TextStyle.height (flutter/engine#52940)
Introduces a sentinel value `kTextHeightNone` for `ui.TextStyle.height` which can be used to "unset" the current `TextStyle.height` (and for consistency, it applies to `StructStyle.height` and `ParagraphStyle.height` too). Documentation of `TextStyle.height` can be found [here](https://main-api.flutter.dev/flutter/painting/TextStyle/height.html) (the one from `painting` library not `dart:ui`).
 
part of https://github.com/flutter/flutter/issues/58765: currently `TextStyle.height` uses `null` as the sentinel value for "no height multiplier specified, use the font height", which has conflicting semantics: it means the height multiplier is not set (so the span height is determined by font metrics) but in reality it also means the height should inherit from its parent span (or in `copyWith` context, it means do not override the height).

The new sentinel value `kTextHeightNone` is currently set to `0.0`. This is because skparagraph internally uses 0 for "no height multiplier", so using 0 should minimize the behavior change: 
62f369c759/modules/skparagraph/src/Run.cpp (L65-L67)

This MAY still change the current behavior: for consistency setting `StructStyle.height` / `ParagraphStyle.height` to the sentinel value also unsets the height multiplier which may not be the current behavior.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-05-24 00:16:16 +00:00
Harry Terkelsen
08b343b90d Move pictures from deleted canvases to second-to-last canvas instead of last. (flutter/engine#51397)
Previously, when the number of display canvases exceeded the maximum amount, we would augment the rendering to reduce the number of canvases to the maximum amount, and move the pictures from the deleted canvases to the last canvas. However, this would cause ugly rendering in cases where pictures would render on top of the platform views they were supposed to be underneath.

This is especially noticeable when reproducing this bug: https://github.com/flutter/flutter/issues/144854

This changes things slightly so that the pictures are moved to the second-to-last remaining canvas, so that platform views always render over the pictures they are supposed to.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-05-23 18:36:05 +00:00
Harry Terkelsen
3c9cdc8515 [canvaskit] Add dilate and erode imagefilters (flutter/engine#48553)
Adds `dilate` and `erode` ImageFilters.

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

## 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-05-22 10:42:20 -07:00
David Iglesias
63260fb965 [web] Adds Noto Serif Tibetan fallback font. (flutter/engine#52971)
This PR adds the "Noto Serif Tibetan" fallback font to Flutter Web, so it can render Dzongkha, and other languages in Tibetan script.

(In order to add this fallback font, an automated script is run which updates the versions and glyphs of other fallback fonts at the same time)

(Bundle uploaded to CIPD)

## Issues

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

## Testing

* Added unit test for font resolution with sample text
* Manually, in localhost, using the sample Dzongkha test from the Noto site:

<img width="959" alt="Screenshot 2024-05-21 at 2 01 19 PM" src="https://github.com/flutter/engine/assets/1255594/3f2db34d-c004-4b90-9fda-62a9cff817f9">

```
དེ་ཡང་ འཛམ་གླིང་ནང་གི་ཞི་བདེ་དང་དྲང་ཁྲིམས། དེ་ལས་དལ་དབང་ཚུ་གི་གཞི་འགྱམ་གཙོ་བོ་དེ་
```

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-05-21 22:22:26 +00:00
Harry Terkelsen
a554688620 [canvaskit] Refactor HtmlImageCodec to generalize to different renderers (flutter/engine#52905)
Refactor `HtmlImageCodec` to decouple it from the html renderer so other
renderers can create a `ui.Image` via `Image.decode()`.

## 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-05-20 16:59:06 -07:00
Jason Simmons
6a30864930 Manual roll of Dart SDK from 28e8e94f9e10 to 0b87dfedea5f (flutter/engine#52914)
The invocation of dart2wasm had to be updated because the dart-sdk flag was removed.

(see https://dart.googlesource.com/sdk/+/328ae02be189311aa26e500b8f4839e90362c20b)
2024-05-18 14:36:26 +00:00
auto-submit[bot]
b16181fe6a Reverts "[macOS] Generate universal gen_snapshots (#52885)" (flutter/engine#52913)
Reverts: flutter/engine#52885
Initiated by: cbracken
Reason for reverting: while this patch worked fine, it pushed the mac build bot over its time limit. Previous builds were just squeaking under the wire but seeing timeouts on the mac_host_engine host_release shard after this commit. e.g. https://ci.chromium.org/ui/p/flutter/builders/prod/Mac%20mac_host_engine/10667/overview

Looking at ci.yaml I see the timeout is set to 240, but the timeout on the failing shard is c
Original PR Author: cbracken

Reviewed By: {jmagman}

This change reverts the following previous change:
Previously, the `gen_snapshot_arm64` and `gen_snapshot_x64` binaries used by the tool were all built for x64 architecture. As such, developers building apps with Flutter rely on Rosetta translation with every build.

This refactors the gen_snapshot build rules on macOS hosts to consistently produce `gen_snapshot_arm64` and `gen_snapshot_x64` binaries with the target architecture of the build but with as universal binaries with both host architectures.

### arm64 host build

Prior to this patch we emitted:
* gen_snapshot_arm64 (arch: x64, target_arch: simarm64)

After this patch, we emit:
* artifacts_x64/gen_snapshot_arm64 (arch: x64, target_arch: simarm64)
* artifacts_arm64/gen_snapshot_arm64 (arch: arm64, target_arch: arm64)
* gen_snapshot_arm64 (universal binary composed of both of the above)

### x64 host build

Prior to this patch we emitted:
* gen_snapshot_x64 (arch: x64, target_arch: x64)

After this patch, we emit:
* artifacts_x64/gen_snapshot_x64 (arch: x64, target_arch: x64)
* artifacts_arm64/gen_snapshot_x64 (arch: arm64, target_arch: simx64)
* gen_snapshot_x64 (universal binary composed of both of the above)

Note that host builds on macOS currently default to a host architecture of x64 (can be overridden via `--force-mac-arm64`) regardless of host architecture and thus, the build itself relies on Rosetta translation when invoked on Apple Silicon arm64 hardware. This is to ensure a consistent build in CI regardless of bot architecture. See: 0d2b0cd0ed/tools/gn (L502-L505)

Issue: https://github.com/flutter/flutter/issues/101138
Issue: https://github.com/flutter/flutter/issues/69157

Related issue: https://github.com/flutter/flutter/issues/103386

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-05-17 23:35:47 +00:00
Chris Bracken
f73900ba16 [macOS] Generate universal gen_snapshots (flutter/engine#52885)
Previously, the `gen_snapshot_arm64` and `gen_snapshot_x64` binaries used by the tool were all built for x64 architecture. As such, developers building apps with Flutter rely on Rosetta translation with every build.

This refactors the gen_snapshot build rules on macOS hosts to consistently produce `gen_snapshot_arm64` and `gen_snapshot_x64` binaries with the target architecture of the build but with as universal binaries with both host architectures.

### arm64 host build

Prior to this patch we emitted:
* gen_snapshot_arm64 (arch: x64, target_arch: simarm64)

After this patch, we emit:
* artifacts_x64/gen_snapshot_arm64 (arch: x64, target_arch: simarm64)
* artifacts_arm64/gen_snapshot_arm64 (arch: arm64, target_arch: arm64)
* gen_snapshot_arm64 (universal binary composed of both of the above)

### x64 host build

Prior to this patch we emitted:
* gen_snapshot_x64 (arch: x64, target_arch: x64)

After this patch, we emit:
* artifacts_x64/gen_snapshot_x64 (arch: x64, target_arch: x64)
* artifacts_arm64/gen_snapshot_x64 (arch: arm64, target_arch: simx64)
* gen_snapshot_x64 (universal binary composed of both of the above)

Note that host builds on macOS currently default to a host architecture of x64 (can be overridden via `--force-mac-arm64`) regardless of host architecture and thus, the build itself relies on Rosetta translation when invoked on Apple Silicon arm64 hardware. This is to ensure a consistent build in CI regardless of bot architecture. See: 0d2b0cd0ed/tools/gn (L502-L505)

Issue: https://github.com/flutter/flutter/issues/101138
Issue: https://github.com/flutter/flutter/issues/69157

Related issue: https://github.com/flutter/flutter/issues/103386

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-05-17 21:24:52 +00:00
auto-submit[bot]
ea811b97ba Reverts "Manual roll of Clang from 725656bdd885 to 145176dc0c93 (#52823)" (flutter/engine#52890)
Reverts: flutter/engine#52823
Initiated by: zanderso
Reason for reverting: Engine crashes on framework CI following this roll https://ci.chromium.org/ui/p/flutter/builders/prod/Linux_android%20flutter_gallery__transition_perf_with_semantics/12126/overview
Original PR Author: jason-simmons

Reviewed By: {zanderso}

This change reverts the following previous change:
See https://github.com/flutter/flutter/issues/143178
2024-05-16 22:01:38 +00:00
Jason Simmons
31d7cb2870 Manual roll of Clang from 725656bdd885 to 145176dc0c93 (flutter/engine#52823)
See https://github.com/flutter/flutter/issues/143178
2024-05-16 17:16:21 +00:00
auto-submit[bot]
d810c59879 Reverts "Revamp the engine style guide, remove always_specify_types. (#52859)" (flutter/engine#52867)
Reverts: flutter/engine#52859
Initiated by: zanderso
Reason for reverting: This sort of change *is* in scope for a discussion at the Dash forum.
Original PR Author: matanlurey

Reviewed By: {cbracken, gaaclarke, johnmccutchan}

This change reverts the following previous change:
Based on the (internal) discussion around converging on using the official Dart style guide, with the exception of the code that gets published under `dart:ui`, as that is user-facing, and we'd like to evolve the code style in conjunction with the framework.

I also took the opportunity to specify more about our style guide use in general, mostly to make it easier to understand our conventions, and also call out known problem areas (notably, our over-use of `shared_ptr` and `auto` in some cases). I am happy to split those up, but it was easier to make the markdown changes at once.

I also took @cbracken and folks advice and clarified directly that explicit types in Dart are _not_ bad (with examples).
2024-05-16 02:51:50 +00:00
Matan Lurey
706817bd67 Revamp the engine style guide, remove always_specify_types. (flutter/engine#52859)
Based on the (internal) discussion around converging on using the official Dart style guide, with the exception of the code that gets published under `dart:ui`, as that is user-facing, and we'd like to evolve the code style in conjunction with the framework.

I also took the opportunity to specify more about our style guide use in general, mostly to make it easier to understand our conventions, and also call out known problem areas (notably, our over-use of `shared_ptr` and `auto` in some cases). I am happy to split those up, but it was easier to make the markdown changes at once.

I also took @cbracken and folks advice and clarified directly that explicit types in Dart are _not_ bad (with examples).
2024-05-16 01:07:17 +00:00
Chinmay Garde
f20b17a2ae [Impeller] Prepare a SkiaGPU-less iOS build. (flutter/engine#52748)
The size of the LTO build of the engine with the dylib compressed is as follows:

```sh
$ du -k libFlutter*
5236	libFlutter.dylib.tar.gz
4324	libFlutterSlimpeller.dylib.tar.gz
```

Sizes are in KiB. This represents a binary size reduction of 17.41% of the compressed artifacts. The compression ratios will likely differ based on the compression scheme.

Uncompressed, the sizes are:

```sh
$ du -k libFlutter*
16920	libFlutter.dylib
14044	libFlutterSlimpeller.dylib
```

This represents a binary size reduction of 16.99% which is in the same ballpark.

The really mucky bit was backing out the raster cache and persistent cache. I want to clean that up in a later patch so that those TUs are part of a separate submodule.

Opting out of Impeller will lead to a fatal log at startup saying the opt-out is disallowed.

Fixes https://github.com/flutter/flutter/issues/126606
2024-05-13 21:43:47 +00:00
Zachary Anderson
a1257de605 Simplify GN pools, use in more places (flutter/engine#52721)
This PR changes from using a different GN pool for each non-compiler tool, to using one GN pool for everything.

Additionally, since we are no longer linking remotely in any configuration, this PR uses the pool for linking.

ObjC and impellerc tasks also do not (yet) run on RBE, so they are also now governed by the pool.

Needs https://github.com/flutter/buildroot/pull/856
2024-05-10 22:43:23 +00:00
Jonah Williams
578e769483 [Impeller] treat glyph atlas texture as source of truth, remove copy of SkBitmap. (flutter/engine#52567)
Work towards part of https://github.com/flutter/flutter/issues/138798

Allow updating single glyphs in the glyph atlas, without replacing the entire bitmap. Required to efficiently append/update to large atlases.
2024-05-10 21:39:47 +00:00
Harry Terkelsen
740e431a9d [canvaskit] Clip before applying ColorFilter so it doesn't filter beyond child bounds (flutter/engine#52704)
When a ColorFilter affects transparent black, it will expand its bounds
to the entire screen, even if the `saveLayer` call is bounded. This
applies a clip before applying the ColorFilter so the filter is bounded
to just the child drawings.

Also fixes bug with ColorFilter being used as an ImageFilter.

Before:

![canvaskit_colorfilter_bounds_before](https://github.com/flutter/engine/assets/1961493/25394b40-c40d-44fb-9c78-9638a40d3329)

After:

![canvaskit_colorfilter_bounds_after](https://github.com/flutter/engine/assets/1961493/b25e4084-ccae-4e41-b6e6-37e8cbbd9d54)

Fixes https://github.com/flutter/flutter/issues/88866
Fixes https://github.com/flutter/flutter/issues/144015

## 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-05-10 12:48:41 -07:00
Zachary Anderson
9d6bf0d3b0 Revert "Various documentation improvements (#52600)" (flutter/engine#52709)
Reverts flutter/engine#52623

Reason for revert is noted on the PR.
2024-05-10 07:54:51 -07:00
Ian Hickson
f0f469735d Various documentation improvements (#52600) (flutter/engine#52623)
This is a reland of https://github.com/flutter/engine/pull/52600 which
was reverted in https://github.com/flutter/engine/pull/52607 due to a
typo.
2024-05-09 15:33:52 -07:00
Yegor
de5ce1e4dc [web] scale semantic text elements to match the desired focus ring size (flutter/engine#52586)
Due to https://g-issues.chromium.org/issues/40875151?pli=1&authuser=0
and a lack of an ARIA role for plain text nodes (after the removal of
`role="text"` in WebKit recently), there is no way to customize the size
of the screen reader focus ring for a plain text element. The focus ring
always tightly hugs the text itself.

A workaround implemented in this PR is to match the size of the text
exactly to the desired focus ring size. This is done by measuring the
size of the text in the DOM, then scaling it both vertically and
horizontally to match the size requested by the framework for the
corresponding semantics node.

To avoid serious performance penalty, the following optimizations were
included:

- Nodes that are satisfiable by just an `aria-label` do not need this
workaround, and are skipped.
- Nodes that must use DOM text (e.g. links, buttons) but have ARIA roles
that size them based on the element, do not need this workaround, and
are skipped.
- Nodes that do need the workaround are first measured in a single
batch, incurring only one page reflow. Then they are all updated in a
single batch without taking any further DOM measurements. This ensures
that no matter how many text spans are rendered, only one reflow is
needed to measure them all.
- Nodes that need the workaround cache the previous label and size, and
if they do not change, the size is not updated.

Other changes:

- Rename `LeafLabelRepresentation` to `LabelRepresentation`, because
labels also apply to non-leaf nodes (e.g. `aria-label` may be applied to
a container).
- Rename `labelRepresentation` to `preferredLabelRepresentation`,
because a particular label representation cannot be guaranteed. A node
that currently looks like a leaf text node may turn out to be an empty
container, and after adding children to it must switch from using DOM
text to an `aria-label`. Therefore, role manager only specify a
preference, but `LabelAndValue` ultimately decides which representation
is usable.
- Introduce `void initState()` in `PrimaryRoleManager` to be used for
one-time initialization of state and DOM structure after all objects
that are in a one-to-one relationship with each other create all the
references needed to establish that relationship (`PrimaryRoleManager`,
`SemanticsObject`, `element`, `owner`, etc). This is not available at
the time the constructors are called.

Fixes https://github.com/flutter/flutter/issues/146774.
2024-05-09 15:23:22 -07:00
Jonah Williams
d790b88806 [Impeller] Support copy from buffer to texture for GLES blitpass, use blit pass to set contents in glyph atlas. (flutter/engine#52510)
part of https://github.com/flutter/flutter/issues/138798

Works around https://github.com/flutter/flutter/issues/144498 for the glyph atlas.

Adds BlitPass::AddCopy implementation for GLES, which is mostly a copy of Texture::SetContents. Updates the glyph atlas to use a blit pass and device private textures instead of set contents (which is unsafely on Metal).

This also removes DeviceBuffer::AsTexture, which isn't actually used anywhere - and creates a linear texture on iOS (and fails with an unsupported API on simulators).

Note that in general, we don't actually have support for hostVisible textures on GLES _or_ Vulkan. Instead, VMA is falling back to device private textures. We may want to, separately, remove the concept of host visible from textures - and similarly remove the concept of transient from buffers.
2024-05-08 00:02:22 +00:00
auto-submit[bot]
9c144b5c05 Reverts "Various documentation improvements (#52600)" (flutter/engine#52607)
Reverts: flutter/engine#52600
Initiated by: zanderso
Reason for reverting: Failing to roll to the framework on a snippet analysis failure: https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8748612253464522177/+/u/run_test.dart_for_analyze_shard_and_subshard_None/stdout
Original PR Author: Hixie

Reviewed By: {jonahwilliams}

This change reverts the following previous change:
No description provided.
2024-05-07 14:09:47 +00:00
Ian Hickson
a6ad5a09b2 Various documentation improvements (flutter/engine#52600) 2024-05-07 06:59:54 +00:00
Harry Terkelsen
b28f8f5c42 [canvaskit] Round physical size to nearest whole number pixels (flutter/engine#52467)
The physical size is computed by multiplying the browser's `innerWidth`
and `innerHeight` by the `devicePixelRatio`. The physical size should be
an integer number of pixels. However, there may be some imprecision and
the result of the multiplication is not quite an integer. This change
rounds the physical size to integers before using them for drawing the
scene.

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

## 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-05-02 16:16:50 -07:00
Juanjo Tugores
3ec84538ca Put the view focus functionality behind a (disabled by default) flag (flutter/engine#52527)
Put the view focus functionality behind a (disabled by default) flag

Should unblock https://github.com/flutter/flutter/pull/143259

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-05-02 21:27:23 +00:00
Alexander Aprelev
8bd9e60267 Use new Dart_PortEx api to ensure SendPort can be rebuild properly. (flutter/engine#52498)
Currently used Dart API can not be reliably used to rebuild dart
SendPort object, [new API was introduced in dart sdk
](https://dart.googlesource.com/sdk/+/de4029ee1ba3bc89d839ae7d2fd0706d29abae58)
and this PR moves flutter engine to use that new API.

BUG: https://github.com/flutter/flutter/issues/147469
2024-05-02 09:06:38 -07:00
Ian Hickson
8966c48831 Remove rasterizerTracingThreshold, checkerboardRasterCacheImages, and checkerboardOffscreenLayers, etc (flutter/engine#52446) 2024-05-02 04:35:04 +00:00
David Iglesias
829ae71a50 [web] Expose browser_detection through ui_web. (flutter/engine#52380)
This PR moves the core of `browser_detection.dart` to a location in `dart:ui_web` so it can be used by apps and plugins.

In order for the code to be a little bit tidier in ui_web, it's encapsulated in a singleton instance that can be accessed through `BrowserDetection.instance` or a top level global `browser` in `dart:ui_web`.

## Issues

* Needed to fix: https://github.com/flutter/flutter/issues/128943
* Needed to land: https://github.com/flutter/flutter/pull/147346

## Tests

Updated affected tests. Mostly the update was to call the methods from `web_ui.browser.methodName` rather than a global scope. Also split the tests for this module in two files:

* `engine_browser_detect_test.dart` - with the tests specific to the engine (capability detection, etc...)
* `browser_detect_test.dart` - only the tests pertaining to the "core" of the library.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-05-02 01:20:10 +00:00
Jackson Gardner
bd471f7a8a [skwasm] Don't mark the backend texture as mipmapped, since it isn't. (flutter/engine#52501)
We don't actually produce mipmaps for any of the textures generated through the `TextureSourceImageGenerator`, even if it is requested of us. So we shouldn't mark the texture as mipmapped in this case. This will allow rendering mechanisms to fall back to a non-mipmapped rendering strategy as needed.
2024-05-02 00:08:05 +00:00
gaaclarke
4429b2f2fe [Impeller] Implements retry for Picture.toImage (flutter/engine#52470)
fixes https://github.com/flutter/flutter/issues/146990

## 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-05-01 08:53:54 -07:00
Jackson Gardner
0d496c4a9e [skwasm] Change default FilterQuality to None for image shaders. (flutter/engine#52468)
This brings the behavior in line with the CanvasKit renderer, which also uses `None` for the default image shader quality.

I added a few unit tests to cover different filter qualities. It turns out, there is a skia issue that manifests both in CanvasKit and Skwasm when a lazy image is rendered with medium quality. See https://g-issues.skia.org/issues/338095525
2024-05-01 00:07:22 +00:00
Kaylee Lubick
b763678f03 Make SkUnicode explicitly instead of relying on SkParagraph to make it for us (flutter/engine#52086)
In https://skia-review.googlesource.com/c/skia/+/838417 Skia staged the
removal of automatically creating an SkUnicode as part of the effort to
make Skia more modular. Clients will now have to construct and SkUnicode
and pass it to SkParagraph to provide the appropriate data. Flutter
sometimes uses ICU and sometimes uses a "client" SkUnicode which makes
use of the browser APIs to get the data.

We should come back to the skwasm code especially, because right now
skwasm gets the data necessary to make an SkUnicode::Client, but stores
it in the ParagraphBuilder, just to take it out again later to make the
SkUnicode::Client and pass that back into the ParagraphBuilder. skwasm
should just create the SkUnicode::Client directly and pass it to the
ParagraphBuilder::make().

## 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.
- [ ] 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-04-29 11:59:33 -04:00
Jonah Williams
8f21d27541 [Impeller] fix GLES image upload. (flutter/engine#52430)
TLDR: this was a load bearing closure.

See https://ci.chromium.org/ui/p/flutter/builders/prod/Linux_pixel_7pro%20complex_layout_scroll_perf_impeller_gles__timeline_summary/1492/overview
2024-04-29 14:24:21 +00:00
Jonah Williams
584a0394aa [Impeller] remove image upload from IO thread, limit concurrent worker threads. (flutter/engine#52423)
Fixes https://github.com/flutter/flutter/issues/123058
Fixes https://github.com/flutter/flutter/issues/135443

We're currently using the IO thread to bottleneck image uploads. Instead, just use fewer concurrent worker threads - and cap the limit at something small. For a Pixel device, this should use about 2 threads maximum, instead of  5 (4 worker and 1 IO).
2024-04-28 17:22:15 +00:00
Tong Mu
94448fc97f Move PointerDataPacketConverter from PlatformView to RuntimeController (flutter/engine#51952)
This is a refactor that moves the `PointerDataPacketConverter` from `PlatformView` to `RuntimeController`. 

This change is made for the following reasons:
- Currently, the pointer data conversion contains no platform specific logic (because the current converter's only responsibility is to make the event sequence conform Flutter's protocol). Therefore these logics should reside in a platform-independent place.
- The converter typically converts one event to many. It's better to have this conversion later than earlier.
- It removes a member from `PlatformView`, making it closer to a pure virtual class.

The reason to choose `RuntimeController` as the destination is because `RuntimeController` manages a map for views, which is required for the converter to implement a later patch https://github.com/flutter/engine/pull/51925.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-04-26 23:45:21 +00:00
Jonah Williams
5935f48862 [Impeller] while we still have benchmarks, see if we're efficient enough for this to be faster. (flutter/engine#52398)
We don't need to decode images to a malloc'd buffer, but this benchmarked as faster because we did so much allocation during the frame. Maybe this is better now? Lets run the benchmarks
2024-04-25 21:12:10 +00:00
Jonah Williams
9dbe934a9b [Impeller] kick off registration and initial PSO compilation of runtime effect earlier. (flutter/engine#52381)
I thought about changing this API so that it blocks on compilation, but I think that isn't necesasary as the workload can happen while the UI thread is building. Plus, even blocking on shader completion does not guarantee that we won't need to compile a variant anyway.

While I was at it I moved the descriptor sets computation to the runtime effect constructor.

With this change the pipleine variant used during the frame is produced much faster than the initial 12ms compilation.

![image](https://github.com/flutter/engine/assets/8975114/42626676-0a71-4503-a3e9-4109c36fbbef)

Fixes https://github.com/flutter/flutter/issues/113719
Fixes https://github.com/flutter/flutter/issues/141222
2024-04-25 20:23:56 +00:00
Ian Hickson
b7117adf38 Document the new binding hooks for SceneBuilder, PictureRecorder, Canvas (flutter/engine#52374)
See https://github.com/flutter/flutter/pull/147271 for context.

Do not land until https://github.com/flutter/flutter/pull/147271 has landed.
2024-04-25 03:05:20 +00:00
Yegor
20e2de3a37 [web:tests] switch to new HTML DOM matcher (flutter/engine#52354)
Remove the over-architected and under-utilized `canonicalizeHtml` and `HtmlComparisonMode`. Replace with a new `hasHtml` matcher.

The new matcher produces considerably better error messages when matching fails (see `matchers_test.dart` for multiple examples). It also allows focusing on particular parts of the DOM rather than looking for a full match. This way a test can test just the functionality it cares about, and it can skip specifying what unrelated parts should look like (i.e. it prevents over-testing). For example, let's say you want to test that an `<flt-semantics>` element has an `aria-label` attribute. You can use a DOM pattern that specified just that:

```
expect(
  element,
  hasHtml('<flt-semantics aria-label="hello"></flt-semantics>'),
)
```

This will check for the existence of `<flt-semantics>` and `aria-label="hello"`. It will ignore everything else that's unrelated to ARIA labels. For example, the element may have its geometry specified in the `style` attribute, an `id` attribute, and many other things, but if the test doesn't care, it doesn't need to specify those things (it can, if needs to though). This also applies to `style` properties. See more examples in the `matchers_test.dart` file.
2024-04-24 20:40:06 +00:00
Jackson Gardner
7b6f8eae5e [skwasm] Fix sampling options for low filter quality to match CanvasKit. (flutter/engine#52331)
These sampling options didn't match up with what CanvasKit was using. I also changed the tests to render images in all four image qualities on a golden.
2024-04-23 19:58:17 +00:00
Kaylee Lubick
17a78534c6 [skia] Remove no-op GN flag (flutter/engine#52121)
After <https://skia-review.googlesource.com/c/skia/+/826440> this flag
does nothing.

## 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.
- [ ] 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-04-23 07:57:59 -04:00
hellohuanlin
cabd4fcacd [ios_edit_menu]add native edit menu (flutter/engine#50095)
Support native edit menu on the engine side. 

Design doc: https://docs.google.com/document/d/16-8kn58h_oD902e7vPSh6W20aHRBJKyNOdSe5rbAe_g/edit?resourcekey=0-gVdJ3fbOybV70ZKeHU7fkQ&tab=t.0

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

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

*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
2024-04-22 23:36:18 +00:00
Harry Terkelsen
37db59763d [canvaskit] Add configuration for maximum canvases (flutter/engine#51735)
Allows developers to customize the maximum amount of overlay canvases.

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

## 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-04-22 10:56:26 -07:00