3725 Commits

Author SHA1 Message Date
Yegor
5d341acdc5 [web] implement selectable semantics (flutter/engine#55970)
Implement `SemanticsFlag.hasSelectedState` and `SemanticsFlag.isSelected` for web in terms of `aria-selected`.

Fixes https://github.com/flutter/flutter/issues/66673
2024-10-21 20:24:10 +00:00
Mouad Debbar
2af8c83f84 [web] Support woff2 fonts (flutter/engine#55908)
- Enable support for WOFF2 fonts.
- Add Brotli depndency (increases CK size by ~53KB compressed, including the Brotli dictionary).
- Use split WOFF2 fonts for Emoji.
- Remove the `useColorEmoji` runtime config flag.

Partially based off of https://github.com/flutter/engine/pull/41282
Fixes https://github.com/flutter/flutter/issues/119536
Contributes to https://github.com/flutter/flutter/issues/153974 and opens the door for moving more fonts to WOFF2.
2024-10-21 13:38:22 +00:00
Jonah Williams
73ec326b80 [UI] fix scene builder parameter naming. (flutter/engine#55969)
This is reponsible for the bdf golden breaking shader mask.
2024-10-18 17:45:23 -07:00
Jonah Williams
f0f29ce37f [Impeller] add mechanism for sharing bdf inputs. (flutter/engine#55701)
Introduces a mechanism to allow backdrop filters to 1) share backdrop inputs and 2) fuse filter applications for faster blurs.

This is a proposed solution to https://github.com/flutter/flutter/issues/131568

Implemented:
* Developer can specify a "backdrop id" which indicates that a backdrop layer should share the input texture and potentially cached filter for a layer.
* Removes second save layer for each backdrop filter
* Removes save layer trace event for backdrop filter
* Can fuse backdrop filters if there is more than one identical filter

TBD:
* Adjust heruristic to avoid applying bdf filter to entire screen

Suggestions: applying a bdf should be a distinct operation from a save layer in the DL builder/dispatcher. The saveLayer implmenentation in the impeller dispatcher is super convoluted because it needs to handle both.

### Video

Video starts with normal bdf then I hot reload to specify that the bdfs share inputs/filters. This is running on a pixel 8 pro

Change to the macrobenchmark app is just:
```dart
  Widget build(BuildContext context) {
    Widget addBlur(Widget child, bool shouldBlur) {
      if (shouldBlur) {
        return ClipRect(
          child: BackdropFilter(
            filter: ImageFilter.blur(sigmaX: 5, sigmaY: 5),
            backdropId: 1, // Added ID
            child: child,
          ),
        );
      } else {
        return child;
      }
    }
```

https://github.com/user-attachments/assets/22707f97-5825-43f1-91b4-1a02a43437f5

Requires framework changes in https://github.com/jonahwilliams/flutter/pull/new/backdrop_id
2024-10-18 15:38:34 +00:00
Jonah Williams
7a2227ddc8 [Impeller] simpler labels for render target textures and cmd buffers. (flutter/engine#55936)
Avoid Sprintf'ing labels for textures/cmd buffers/render passes. For the render target textures, defer combined label construction until we know the label will be used.
2024-10-18 04:01:50 +00:00
Brandon DeRosier
518ada1675 [Flutter GPU] Remove Command/VertexBuffer usage from Flutter GPU. (flutter/engine#55893)
Resolves https://github.com/flutter/flutter/issues/156764.
Resolves https://github.com/flutter/flutter/issues/155335.

- Remove Command/VertexBuffer from Flutter GPU.
- Separate vertex/index count into `impeller::RenderPass::SetElementCount(size_t count)` & accurately document its behavior.
- Make Flutter GPU uniform/texture bindings re-assignable.
- Remove unnecessary templates.
2024-10-17 22:39:19 +00:00
Yegor
4a93a6a08b Introduce SemanticsFlag.hasSelectedState to the engine API (flutter/engine#55780)
Introduce `SemanticsFlag.hasSelectedState` to the engine API. At this point the flag is not backed by any engine functionality. See also: https://github.com/flutter/flutter/issues/66673#issuecomment-2402903402

| ⚠️ WARNING           |
|:----------------------------|
| Submit _AFTER_ https://github.com/flutter/flutter/pull/157017 and https://github.com/flutter/flutter/pull/157061 land in the framework     |

A step towards https://github.com/flutter/flutter/issues/66673
2024-10-17 22:01:34 +00:00
Jonah Williams
243ea95602 [Impeller] make labeling APIs exclusively use std::string_view. (flutter/engine#55918)
Many of our labeling APIs accepted a std::string. When provided with a string literal (const char*), this would force the allocation of a new std::string object and a copy of the original char*. std::string_view is a view of either a std::string, or a const char* (or other), which allows an API that doesn not need to store the string to accept both without a copy. Of course, we can't store a std::string_view, as that doesn't provide memory ownership - so many of the GLES implementations will still copy the string_view into a string locally.

Also updates several of the debug labelling functions to no-op in release mode and removes some expensive interpolations that aren't super necessary.
2024-10-17 16:54:03 +00:00
Jonah Williams
5c6ab792a2 [Impeller] fix memory leak during gif upload. (flutter/engine#55920)
Fixes https://github.com/flutter/flutter/issues/156728

Need to periodically flush the TLS command buffer pools in multiframe codec just like single frame codec.
2024-10-17 01:17:59 +00:00
Harlen Batagelo
8737cce879 Handle out-of-order add/remove pointer events (flutter/engine#55740)
Fixes [#146251](https://github.com/flutter/flutter/issues/146251).

On Windows, a "pointer add" event to a new view is sometimes sent before the "pointer remove" event from the old view. When `PointerDataPacketConverter` handles the add event, it asserts that the device's pointer state has been cleared. Since the pointer state is cleared only when the remove event is processed, the assertion fails if the events arrive out of order.

The solution proposed here is to synthesize a remove event if an add event is received while the pointer state hasn't been cleared (i.e., if the pointer is added without being removed from the previous view).

To avoid duplicate remove events, the view ID is now tracked in `PointerState`. If the original "remove" arrives after the synthesized one, the state's view ID will differ from the pointer data's view ID, allowing it to be safely ignored.

When synthesizing the remove event, it's possible that the old view has already been destroyed, meaning no remove event will be received later. For example, this occurs when a window is destroyed while the pointer is inside it. However, the framework expects an "add" event to always follow a "remove" event, and "remove" events with invalid views are ignored. To meet the framework's expectations, the view ID of the "add" event will be used for the "remove" event if the old view has been destroyed.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-10-16 20:19:49 +00:00
Brandon DeRosier
50b5307332 [Impeller] Allow binding multiple vertex buffer views. (flutter/engine#55856)
Resolves https://github.com/flutter/flutter/issues/116168.
(Continuation of https://github.com/flutter/engine/pull/49670)

Makes it possible for us to use arbitrary vertex layouts, including SoA layouts with attributes stored in different DeviceBuffers. CanRenderPerspectiveCube was converted to an SoA attribute layout with two separate buffers as an example.

Works on all the backends!

OpenGLES:
<img width="1136" alt="image" src="https://github.com/user-attachments/assets/e2398fde-532f-402d-899a-39aaa556f24f">

Vulkan:
<img width="1136" alt="image" src="https://github.com/user-attachments/assets/1c1bf664-bec1-43cb-ab2e-eb2a74718bfd">

Metal:
<img width="1136" alt="image" src="https://github.com/user-attachments/assets/bf59da17-cf52-4913-88e4-ab6f0bd6fc96">
2024-10-15 01:13:52 +00:00
Brandon DeRosier
778e32ec0d [Flutter GPU] Remove unused fixture. (flutter/engine#55869)
I used this fixture data early on to bootstrap testing for Flutter GPU before shader bundles were finished. But today we have the build system compile shader bundles for us, so this is no longer used.
2024-10-15 00:10:21 +00:00
David Iglesias
0d39b59999 [web] Ensure Flutter adds a generator meta-tag. (flutter/engine#55714)
Adds a `meta name="generator" content="Flutter"` tag when the engine UI initializes.

## Issues

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

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-10-14 18:41:51 +00:00
AthulJoseph
3214f65fa3 [Impeller] Added support to set polygon mode in Flutter GPU. (flutter/engine#55804)
Added support to set polygon mode in Flutter GPU. This fixes the issue [#142732](https://github.com/flutter/flutter/issues/142732).
2024-10-12 01:07:36 +00:00
Yegor
e478ea9bad [web:a11y] make header a proper <header> (flutter/engine#55747)
Now that we have [proper headings](https://github.com/flutter/engine/blob/main/lib/web_ui/lib/src/engine/semantics/heading.dart), headers should become proper headers.

Fixes https://github.com/flutter/flutter/issues/152268
2024-10-09 22:21:51 +00:00
auto-submit[bot]
eae94cf3df Reverts "Reverts "Run gen_snapshot under /usr/bin/time (#55777)" (#55787)" (flutter/engine#55789)
Reverts: flutter/engine#55787
Initiated by: matanlurey
Reason for reverting: We determined this was an expected failure.
Original PR Author: auto-submit[bot]

Reviewed By: {fluttergithubbot}

This change reverts the following previous change:
Reverts: flutter/engine#55777
Initiated by: matanlurey
Reason for reverting: Breaks CI postsubmit (https://ci.chromium.org/ui/p/flutter/builders/prod/Mac%20Production%20Engine%20Drone/485517/overview).
Original PR Author: aam

Reviewed By: {matanlurey}

This change reverts the following previous change:
This should help further troubleshoot https://github.com/flutter/flutter/issues/154437
2024-10-09 21:31:46 +00:00
auto-submit[bot]
93d9a4e1ed Reverts "Run gen_snapshot under /usr/bin/time (#55777)" (flutter/engine#55787)
Reverts: flutter/engine#55777
Initiated by: matanlurey
Reason for reverting: Breaks CI postsubmit (https://ci.chromium.org/ui/p/flutter/builders/prod/Mac%20Production%20Engine%20Drone/485517/overview).
Original PR Author: aam

Reviewed By: {matanlurey}

This change reverts the following previous change:
This should help further troubleshoot https://github.com/flutter/flutter/issues/154437
2024-10-09 21:18:46 +00:00
Alexander Aprelev
de3410f8f4 Run gen_snapshot under /usr/bin/time (flutter/engine#55777)
This should help further troubleshoot https://github.com/flutter/flutter/issues/154437
2024-10-09 20:47:36 +00:00
Brandon DeRosier
e118869e40 [Flutter GPU] Get the GLES backend/Windows working. (flutter/engine#55694)
Resolves https://github.com/flutter/flutter/issues/156305.

* Resolve pipelines and submit command buffers on the raster thread.
* Don't use desktop GL shader variation on Windows.
* Fix interpretation of `array_elements`.
* Fix texture binding metadata.

Gets Flutter GPU working on Windows!
![image](https://github.com/user-attachments/assets/9eecb67f-a980-4556-8060-b0c947713534)
![image](https://github.com/user-attachments/assets/c8e2071f-e7c0-411c-8f37-e1f3037916f4)
2024-10-09 00:04:39 +00:00
Harry Terkelsen
0ed39374df [canvaskit] Fix incorrect clipping with Opacity scene layer (flutter/engine#55751)
Fixes opacity layer incorrectly clipping its children when there are complex transforms applied to them. Since the opacity saveLayer only applies to children which actually draw, it doesn't need to have tight bounds anyways.

Pre-requisite for re-enabling tests here: https://github.com/flutter/flutter/issues/110785

BEFORE:
![Screenshot 2024-10-08 at 11 00 14 AM](https://github.com/user-attachments/assets/cf4c6296-7730-4db6-96f6-e22f32e28d94)

AFTER:
![Screenshot 2024-10-08 at 11 06 22 AM](https://github.com/user-attachments/assets/6a680e2c-23d0-41e2-9de5-1c9667a785ab)

BEFORE:
![failing_opacity](https://github.com/user-attachments/assets/d8acf075-c92d-4f8a-aa1a-476f46f1c931)

AFTER:
![working_opacity](https://github.com/user-attachments/assets/3e589deb-d8b6-4466-9e19-95daff870bfb)

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-10-08 23:49:09 +00:00
AthulJoseph
a01daf5555 Added support to set primitive type (flutter/engine#55514)
Added a way to specify the PrimitiveType when encoding commands in the RenderPass.

This partially fixes the issue #142732
2024-10-08 21:57:10 +00:00
David Iglesias
e2b6520742 [web] Warn users when picking a deprecated renderer. (flutter/engine#55709)
Warn users when they pick a deprecated renderer for the web, and point them to the appropriate /go/ link.

## Issues

* Part of https://github.com/flutter/flutter/issues/145954
* Fixes https://github.com/flutter/flutter/issues/154879

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-10-08 00:16:23 +00:00
Jackson Gardner
db449a1603 Revert "Reland [skwasm] Scene builder optimizations for platform view placement (#55468)" (flutter/engine#55715)
This reverts commit b99e758ee1025d5bab2ecff1d62ff75a17b68996 (https://github.com/flutter/engine/pull/55468)

Reason for revert, devtools has been having rendering issues since this commit. See https://github.com/flutter/devtools/issues/8401
2024-10-08 00:01:15 +00:00
gaaclarke
96b0bf0ce3 Speculative fix for memory issues related to retrying image decompression (flutter/engine#55704)
b/371512414

This issue had no reproduction but the stacktrace was provided.  The theory of this fix is that the `ImageResult` type is capturing something that doesn't handle being copied and deallocated twice so instead of copying it, we std::move it into a shared_ptr so that it will only be deallocated once.

Also, I just avoid using a `std::move` when overflowing.  The idea here is maybe sometimes deleting the std::move'd item isn't kosher.  We know from the stacktrace that it has something to do with overflowing because that would be the only case where something is being deleted.

I've added 2 integration tests that exercises the code where the crash appears to be happening.  This is good coverage to have but neither of them reproduced the issue, even with MallocScribble enabled.  That's the best we can do without a reproduction.

```
Thread 7  (id: 0x0000a103)crashed
0x000000010a48ae8c(Flutter -function.h)std::_fl::allocator<impeller::ContextMTL::PendingTasks>::destroy[abi:v15000](impeller::ContextMTL::PendingTasks*)
0x000000010a48b9fc(Flutter -allocator_traits.h:309)impeller::ContextMTL::StoreTaskForGPU(std::_fl::function<void ()> const&, std::_fl::function<void ()> const&)
0x000000010a48b9fc(Flutter -allocator_traits.h:309)impeller::ContextMTL::StoreTaskForGPU(std::_fl::function<void ()> const&, std::_fl::function<void ()> const&)
0x000000010a4d49e4(Flutter -image_decoder_impeller.cc:422)std::_fl::__function::__func<flutter::ImageDecoderImpeller::UploadTextureToPrivate(std::_fl::function<void (sk_sp<flutter::DlImage>, std::_fl::basic_string<char, std::_fl::char_traits<char>, std::_fl::allocator<char>>)>, std::_fl::shared_ptr<impeller::Context> const&, std::_fl::shared_ptr<impeller::DeviceBuffer> const&, SkImageInfo const&, std::_fl::shared_ptr<SkBitmap> const&, std::_fl::optional<SkImageInfo> const&, std::_fl::shared_ptr<fml::SyncSwitch> const&)::$_1, std::_fl::allocator<flutter::ImageDecoderImpeller::UploadTextureToPrivate(std::_fl::function<void (sk_sp<flutter::DlImage>, std::_fl::basic_string<char, std::_fl::char_traits<char>, std::_fl::allocator<char>>)>, std::_fl::shared_ptr<impeller::Context> const&, std::_fl::shared_ptr<impeller::DeviceBuffer> const&, SkImageInfo const&, std::_fl::shared_ptr<SkBitmap> const&, std::_fl::optional<SkImageInfo> const&, std::_fl::shared_ptr<fml::SyncSwitch> const&)::$_1>, void ()>::operator()()
0x000000010a06c234(Flutter -function.h:512)fml::SyncSwitch::Execute(fml::SyncSwitch::Handlers const&) const
0x000000010a4d42f8(Flutter -image_decoder_impeller.cc:408)flutter::ImageDecoderImpeller::UploadTextureToPrivate(std::_fl::function<void (sk_sp<flutter::DlImage>, std::_fl::basic_string<char, std::_fl::char_traits<char>, std::_fl::allocator<char>>)>, std::_fl::shared_ptr<impeller::Context> const&, std::_fl::shared_ptr<impeller::DeviceBuffer> const&, SkImageInfo const&, std::_fl::shared_ptr<SkBitmap> const&, std::_fl::optional<SkImageInfo> const&, std::_fl::shared_ptr<fml::SyncSwitch> const&)
0x000000010a4d3838(Flutter -image_decoder_impeller.cc:538)std::_fl::__function::__func<flutter::ImageDecoderImpeller::Decode(fml::RefPtr<flutter::ImageDescriptor>, unsigned int, unsigned int, std::_fl::function<void (sk_sp<flutter::DlImage>, std::_fl::basic_string<char, std::_fl::char_traits<char>, std::_fl::allocator<char>>)> const&)::$_1, std::_fl::allocator<flutter::ImageDecoderImpeller::Decode(fml::RefPtr<flutter::ImageDescriptor>, unsigned int, unsigned int, std::_fl::function<void (sk_sp<flutter::DlImage>, std::_fl::basic_string<char, std::_fl::char_traits<char>, std::_fl::allocator<char>>)> const&)::$_1>, void ()>::operator()()
0x000000010a06dd1c(Flutter -function.h:512)fml::ConcurrentMessageLoopDarwin::ExecuteTask(std::_fl::function<void ()> const&)
0x000000010a06737c(Flutter -concurrent_message_loop.cc:101)void* std::_fl::__thread_proxy[abi:v15000]<std::_fl::tuple<std::_fl::unique_ptr<std::_fl::__thread_struct, std::_fl::default_delete<std::_fl::__thread_struct>>, fml::ConcurrentMessageLoop::ConcurrentMessageLoop(unsigned long)::$_0>>(void*)
0x000000021d4ff378(libsystem_pthread.dylib + 0x00006378)_pthread_start
```

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-10-07 20:46:16 +00:00
Brandon DeRosier
3b3ffcb8cd [Flutter GPU] Add WindingOrder. (flutter/engine#55413)
Resolves https://github.com/flutter/flutter/issues/155636.

(Extends test in https://github.com/flutter/engine/pull/55409)
2024-10-05 02:04:04 +00:00
Harry Terkelsen
6d9834ee05 Reland "[canvaskit] Further improve overlay optimization by splitting pictures" (flutter/engine#55563)
This enhances the overlay optimization by delaying combining pictures to get tighter bounds for the pictures that make up the scene, enabling more sophisticated optimization since we can determine if they intersect with platform views on a per-picture basis.

Fixes https://github.com/flutter/flutter/issues/149863
Fixes https://github.com/flutter/flutter/issues/155833

On a Macbook in Chrome in an example app with an infinite scrolling grid of platform views, this brings the ratio of dropped frames from 93% to 55% (roughly 4 fps to 30 fps).

This is a reland of https://github.com/flutter/engine/pull/54878 with a fix for scenes with pictures and shader masks that are eventually entirely clipped out. It also fixes a performance issue caused by making too many Canvases just to record the size of the picture elements in the scene.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-10-02 21:26:46 +00:00
Todd Volkert
7b84f908ec Added Dart docs (flutter/engine#54506)
Added docs to `FrameCallback` and `FrameData`
2024-10-01 22:08:04 -07:00
Jackson Gardner
b99e758ee1 Reland [skwasm] Scene builder optimizations for platform view placement (flutter/engine#55468)
This is an attempt to reland the overlay optimization for skwasm and fixing the golden diffs from the framework tests.

Original PR description:

This PR refactors the scene builder's logic in order to more aggressively merge flutter content and platform view content together. This essentially covers the case discussed in this flutter issue: https://github.com/flutter/flutter/issues/149863

This optimization ensures that each picture or platform view is applied to the lowest possible slice in the scene, which avoids the proliferation of redundant slices and overlays in the scene.
2024-09-30 17:42:58 +00:00
Harry Terkelsen
5c96bcbf1e Revert "Reland "[canvaskit] Further improve overlay optimization by splitting pictures"" (flutter/engine#55501)
Reverts flutter/engine#55464

The PR caused a large regression in a web benchmark.
2024-09-28 00:51:18 +00:00
gaaclarke
9e2746c137 updated Color docstring to address equality (flutter/engine#55496)
issue: https://github.com/flutter/flutter/issues/155803

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-09-27 21:41:08 +00:00
Jason Simmons
96d24ff033 Listen for uncaught exceptions during loading of a web test suite in Chrome (flutter/engine#55166)
Without this the test runner will hang if the compiled test is invalid and unable to execute.
2024-09-27 17:18:18 +00:00
Mouad Debbar
f6e580d09a [web] Update builder json generator to reflect recent changes (flutter/engine#55307)
Recent [changes](https://github.com/flutter/engine/pull/54584) affected our builder configs, but the script that generates those builder configs wasn't updated.
2024-09-27 16:05:17 +00:00
Harry Terkelsen
1e086b6311 Reland "[canvaskit] Further improve overlay optimization by splitting pictures" (flutter/engine#55464)
This enhances the overlay optimization by delaying combining pictures to get tighter bounds for the pictures that make up the scene, enabling more sophisticated optimization since we can determine if they intersect with platform views on a per-picture basis.

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

On a Macbook in Chrome in an example app with an infinite scrolling grid of platform views, this brings the ratio of dropped frames from 93% to 55% (roughly 4 fps to 30 fps).

This is a reland of https://github.com/flutter/engine/pull/54878 with a fix for scenes with pictures and shader masks that are eventually entirely clipped out.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-09-26 21:25:59 +00:00
auto-submit[bot]
2d9833b103 Reverts "Reland "[canvaskit] Further improve overlay optimization by splitting pictures" (#55402)" (flutter/engine#55456)
Reverts: flutter/engine#55402
Initiated by: chingjun
Reason for reverting: caused internal tests to fail.

See b/369740500 for more details.
Original PR Author: harryterkelsen

Reviewed By: {yjbanov}

This change reverts the following previous change:
This enhances the overlay optimization by delaying combining pictures to get tighter bounds for the pictures that make up the scene, enabling more sophisticated optimization since we can determine if they intersect with platform views on a per-picture basis.

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

On a Macbook in Chrome in an example app with an infinite scrolling grid of platform views, this brings the ratio of dropped frames from 93% to 55% (roughly 4 fps to 30 fps).

This is a reland of https://github.com/flutter/engine/pull/54878 with a fix for scenes with pictures that are eventually entirely clipped out.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-09-26 06:19:47 +00:00
Harry Terkelsen
d91038befd Reland "[canvaskit] Further improve overlay optimization by splitting pictures" (flutter/engine#55402)
This enhances the overlay optimization by delaying combining pictures to get tighter bounds for the pictures that make up the scene, enabling more sophisticated optimization since we can determine if they intersect with platform views on a per-picture basis.

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

On a Macbook in Chrome in an example app with an infinite scrolling grid of platform views, this brings the ratio of dropped frames from 93% to 55% (roughly 4 fps to 30 fps).

This is a reland of https://github.com/flutter/engine/pull/54878 with a fix for scenes with pictures that are eventually entirely clipped out.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-09-25 23:47:18 +00:00
Brandon DeRosier
31ac0fc004 [Flutter GPU] Use vm.Vector4 for clear color instead of ui.Color. (flutter/engine#55416)
Resolves https://github.com/flutter/flutter/issues/155627.

Allow setting the clear directly as floats without conversion work. vector_math already has convenient `Colors.[color]` factories and such. Also, `ui.Color` has a color space now, which does not apply here.

Adds a simple golden to verify that clear colors work:
![flutter_gpu_test_clear_color](https://github.com/user-attachments/assets/ba7a4e74-aaf2-48d8-ac13-115a86daeb19)
2024-09-25 18:02:05 +00:00
Brandon DeRosier
e496b1ed26 [Flutter GPU] Add CullMode. (flutter/engine#55409)
Part of https://github.com/flutter/flutter/issues/155636.

New golden `flutter_gpu_test_cull_mode` will draw a red triangle if the CullMode isn't working:
![flutter_gpu_test_cull_mode](https://github.com/user-attachments/assets/cbdf804e-1608-4352-9aa1-d5d9223f3c1a)
2024-09-25 00:52:11 +00:00
John McDole
14caa2fe19 Disallow time traveling frame times (flutter/engine#55310)
Address bad developer experience in
https://github.com/flutter/flutter/issues/106277

Leave as an error log and hope for more repro reports


```mermaid
sequenceDiagram
  Animator ->> Animator: AwaitVSync
  Animator ->> VsyncWaiter: AsyncWaitForVsync(callback)
  VsyncWaiter -> VsyncWaiterAndroid: AwaitVSync
  note over VsyncWaiterAndroid: GetUITaskRunner
  VsyncWaiterAndroid -> Choreographer: PostFrameCallback
  Choreographer -> NDK: AChoreographer_postFrameCallback64
  note over Choreographer,NDK: The time that the frame is being<br/>rendered as nanoseconds in the <br/>CLOCK_MONOTONIC time base
  NDK --> Choreographer: callback(nanos)
  Choreographer -> VsyncWaiterAndroid: callback
  note over VsyncWaiterAndroid: // Rollback suspicion<br/>if (frame_time > now) frame_time = now;
  VsyncWaiterAndroid -> VsyncWaiterAndroid: OnVsyncFromNDK(frame_nanos)
  VsyncWaiterAndroid -> VsyncWaiter: FireCallback(\n  frame_start_time,\n  target_time)
  VsyncWaiter -> Animator: callback(frame_timings_recorder)

  Animator -> Animator: BeginFrame(frame_timings_recorder)
  Animator -> Shell: OnAnimatorBeginFrame
  Shell -> Engine: BeginFrame(frame_time, frame_number)
  Engine -> RuntimeController: BeginFrame(frame_time, frame_number)
  RuntimeController -> PlatformConfiguration: BeginFrame(frame_time, frame_number)
  PlatformConfiguration -> hooks.dart: begin_frame_
```
2024-09-24 15:33:45 -07:00
Jason Simmons
d333cf4224 [Impeller] Delete command pools held by the CommandPoolRecyclerVK after decoding an image on the IO thread (flutter/engine#55398)
In the Vulkan backend, the CommandPoolRecyclerVK stores command pools that can be reused while rendering a frame.  For each frame, SurfaceContextVK::AcquireNextSurface calls CommandPoolRecyclerVK::Dispose to clear the cached pools.

However, the CommandPoolRecyclerVK's cache of pools is placed in thread-local storage.  So command pools used on the IO thread will not be cleaned up if frame rendering calls Dispose on the raster thread.

This PR adds a Context API that the IO thread can call after using a command pool in order to ensure that cached resources are disposed.

Fixes https://github.com/flutter/flutter/issues/155519
2024-09-24 22:16:37 +00:00
Brandon DeRosier
c4514370d7 [Flutter GPU] Add pipeline stencil config. (flutter/engine#55272)
Also adds a golden that depends on https://github.com/flutter/engine/pull/55270.
Resolves https://github.com/flutter/flutter/issues/142731.

Allow setting the stencil compare function, pass/fail operations, and read/write masks.

Flutter GPU has light "shader object" style programs, so all of the stencil configuration state can be set on the `RenderPass` at any time.

New simple golden that exercises stencil ops:
![flutter_gpu_test_triangle_stencil](https://github.com/user-attachments/assets/acc98cd9-41fc-4988-97a2-afb898a8fc0c)
2024-09-24 21:26:29 +00:00
Harry Terkelsen
81f281b72d Revert "[canvaskit] Further improve overlay optimization by splitting pictures" (flutter/engine#55401)
Reverts flutter/engine#54878

Crashes on real example app with many platform views
2024-09-24 13:06:08 -07:00
Harry Terkelsen
31cde4f8d3 [canvaskit] Further improve overlay optimization by splitting pictures (flutter/engine#54878)
This enhances the overlay optimization by delaying combining pictures to get tighter bounds for the pictures that make up the scene, enabling more sophisticated optimization since we can determine if they intersect with platform views on a per-picture basis.

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

On a Macbook in Chrome in an example app with an infinite scrolling grid of platform views, this brings the ratio of dropped frames from 93% to 55% (roughly 4 fps to 30 fps).

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-09-24 19:39:10 +00:00
Brandon DeRosier
7242297f80 [Flutter GPU] Add setStencilReference to RenderPass. (flutter/engine#55270) 2024-09-24 11:27:25 -07:00
Mouad Debbar
d99ff74d1a [web] Fix keyboard not showing up when iOS input has decoration text (flutter/engine#55152)
In certain situations, semantics elements get assigned `pointer-events: none` when they aren't supposed to.

One such situation is when a text field has a [decoration error text](https://api.flutter.dev/flutter/material/InputDecoration/errorText.html). The semantics node become a container, and we always set `pointer-events: none` on container nodes.

This PR introduces an `acceptsPointerEvents` getter on `SemanticRole` and `SemanticBehavior` to control when `pointer-events` should be `all` or `none`.

Fixes https://github.com/flutter/flutter/issues/141975
2024-09-24 15:03:00 +00:00
gaaclarke
9f66178386 Reland: Update Color to do all calculations with floating point components (flutter/engine#55231)
Reason for revert: Broke customer tests
Reland depends on https://github.com/flutter/flutter/issues/155113

This transforms the rest of Color to use the floating point parameters.  This will likely break existing tests very subtly.  For example, colors will be slightly different in golden tests if `lerp` was ever used.

issue: https://github.com/flutter/flutter/issues/127855

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-09-23 17:43:52 +00:00
Brandon DeRosier
a2fe41a763 [Flutter GPU] Remove the redundant smoketest. (flutter/engine#55267)
This is placeholder stuff that I added before the rest of the API to prove that we can call the engine symbols.

Today this is totally redundant as Flutter GPU has a bunch of automated tests which exercise every FFI call.
2024-09-17 22:24:07 +00:00
Brandon DeRosier
759d173073 [Flutter GPU] Add DeviceBuffer.flush & GpuContext.getMinimumUniformByteAlignment. (flutter/engine#53620)
Part of https://github.com/flutter/flutter/issues/150953.

Provide a way to get the required minimum uniform byte alignment when referencing uniform blocks in a device buffer. Allow the user to explicitly flush DeviceBuffers (necessary for devices without shared memory).
2024-09-17 20:31:50 +00:00
Brandon DeRosier
ea026548ce [Flutter GPU] Add golden test for rendering a triangle. (flutter/engine#55262)
Resolves https://github.com/flutter/flutter/issues/144640.

New golden:
![flutter_gpu_test_triangle](https://github.com/user-attachments/assets/0b39380e-1aa5-4369-ae5b-a8764d5701cb)
2024-09-17 20:00:33 +00:00
auto-submit[bot]
86d1435a0d Reverts "[skwasm] Scene builder optimizations for platform view placement (#54949)" (flutter/engine#55193)
Reverts: flutter/engine#54949
Initiated by: eyebrowsoffire
Reason for reverting: Incorrect golden diffs on engine roll, see https://github.com/flutter/flutter/pull/155181
Original PR Author: eyebrowsoffire

Reviewed By: {harryterkelsen}

This change reverts the following previous change:
This PR refactors the scene builder's logic in order to more aggressively merge flutter content and platform view content together. This essentially covers the case discussed in this flutter issue: https://github.com/flutter/flutter/issues/149863

This optimization ensures that each picture or platform view is applied to the lowest possible slice in the scene, which avoids the proliferation of redundant slices and overlays in the scene.
2024-09-13 22:21:47 +00:00
Jim Graham
7da9ad1862 Delete VolatilePathTracker in favor of Dispatch tracking (flutter/engine#55125)
ui.Canvas and ui.SceneBuilder now use the DlPath object directly from the ui.Path object. This results in increased sharing of the wrapper objects which then increases the sharing of both the converted Impeller paths and Skia's volatile flag.

The VolatilePathTracker mechanism is deleted and rather than count the number of frames that a path is stable for, instead we count the number of times it is used for rendering. If a path is used 100 times in a single frame, it will become non-volatile and start being cached almost immediately. The cached Impeller paths are now also tracked for all instances of the same path, rather than for each call site that originated from a DisplayList dispatch.
2024-09-13 21:49:09 +00:00