2929 Commits

Author SHA1 Message Date
Dan Field
842e8cea52 [Impeller] Gpu model information to Skia gold (flutter/engine#41216)
Does two things:

- Exposes a string about the GPU model on `impeller::Context`
- passes that string on to Skia gold when we add a test image.

This should help reduce noise/flakiness in golden images.
2023-04-18 20:11:05 +00:00
Greg Spencer
70e9ea9a3c Some minor doc typo and diagnostic fixes. (flutter/engine#40982) 2023-04-18 10:39:06 -07:00
Jim Graham
d4a56c721b focus SkiaGPUObject wrappers on only those objects that need the protection (flutter/engine#41237)
With this PR we no longer need to hold DisplayLists in GPUObject wrappers and they can be disposed instantly instead of queueing on the Unref thread.

This will definitely be a win for Impeller as none of the objects used in a frame now require queueing, but the performance impact on apps running on top of skia is less clear if they depend on a lot of images inside their DisplayLists that still need to be queued to be freed. After getting further in the work, it looks like only decoded images need to use the protected DlImage wrappers and most of those should survive many frames before they are disposed. That should hopefully leave very few unrefs happening per frame.

~There are 3 unit tests in `shell_unittests.cc` and `embedder_metal_unittests.mm` that are now GSKIP'd as they now invoke code that needs a fully initialized UIDartState in order to protect their images. I will look into fixing the tests and/or making the code they invoke provide protection without relying on UIDartState.~ (This looks to be fixed in the latest commit by simply not creating DlImageGPUs all over the source base and simply catching only those that end up in UI data structures. There is actually existing code in one of the modules that feeds ui.Image with an answer to wrap the image in a DlImageGPU if it has a skia image anyway, so most of these additional uses of DlImageGPU that were having trouble getting the Skia unref queue just didn't need it anyway.)
2023-04-17 23:47:20 +00:00
Jackson Gardner
c2719b8e06 Reland ui_web files in sky_engine (flutter/engine#41169)
Previous attempt was here: https://github.com/flutter/engine/pull/40846

I was including un-rewritten source files, which caused breakage. Now we run out `ui_web` files through the sdk_rewriter script before putting them into sky_engine
2023-04-17 22:31:25 +00:00
Yegor
2fcdf5a731 [web:canvaskit] migrate Paint API to UniqueRef (flutter/engine#41230)
Migrate Paint API to `UniqueRef`. This includes `Paint`, `ImageFilter` (and all subtypes), `ColorFilter` (and all subtypes).

Also fix the following memory leaks:

* `CkPaint` is frequently used by layers where a one-off paint object is created, used, and immediately dropped. `CkPaint` now has a `dispose` method, and all one-off usages now dispose of the paint after they are done.
* `CkColorFilter.initRawImageFilter` was leaking the `SkColorFilter` created by `_initRawColorFilter` inside the expression.
* `CkManagedSkImageFilterConvertible.imageFilter` now takes a closure, which allows the implementation decide on the lifetime of the `SkImageFilter` vended to the caller. Because `CkColorFilter` is a const class it cannot store C++ instances inside its own fields, so it creates a temporary `SkImageFilter` class to be used by the caller and then it needs to delete it. Now it does.
2023-04-17 17:30:19 +00:00
Kevin Lubick
108eb0fa89 Migrate uses of deprecated SkImage->encodeToData (flutter/engine#41204)
In https://skia-review.googlesource.com/c/skia/+/667296, Skia deprecated
`SkImage->encodeToData`.

This PR fixes all uses in Flutter of that API by using SkPngEncoder
directly.

## 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 Hixie said 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].
- [ ] 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
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[C++, Objective-C, Java style guides]:
https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
[testing the engine]:
https://github.com/flutter/flutter/wiki/Testing-the-engine
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
2023-04-17 10:03:40 -07:00
Yegor
d1d577c2ae [web:canvaskit] move shaders to UniqueRef; fix minor memory leaks (flutter/engine#41172)
[web:canvaskit] move shaders to UniqueRef; fix minor memory leaks
2023-04-14 02:57:19 +00:00
LouiseHsu
7f3889d6b0 Revert "Add support for double tap action from Apple Pencil 2" (flutter/engine#41138)
Reverts flutter/engine#39637

Since this feature https://github.com/flutter/flutter/issues/73172 has
been scrapped for now, previous engine work should be reverted. Refer to
[this design
doc](https://docs.google.com/document/d/1r4P5r-jGt2Sjqro3ldCU2axUiHTpu3yhIycnI94OKQw/edit
) for more discussion and details.
2023-04-13 14:59:04 -07:00
Jackson Gardner
29eb026a0e Fix skwasm's canvasDrawArc declaration and write tests. (flutter/engine#41165)
Fix skwasm's canvasDrawArc declaration and write tests.
2023-04-13 21:26:17 +00:00
Jackson Gardner
fb0a83e944 Implement Gradient Shaders and Fragment Shaders in Skwasm (flutter/engine#41144)
Implement Gradient Shaders and Fragment Shaders in Skwasm
2023-04-13 20:58:46 +00:00
Jackson Gardner
a301d289d5 Revert "Include ui_web API files in sky_engine." (flutter/engine#41143)
Revert "Include `ui_web` API files in sky_engine."
2023-04-13 01:14:54 +00:00
Yegor
aa5cde7646 [web:canvaskit] move path API to UniqueRef (flutter/engine#41136)
[web:canvaskit] move path API to UniqueRef
2023-04-12 23:52:26 +00:00
Jackson Gardner
56821f80e7 Don't use OffscreenCanvas in Safari, it doesn't support WebGL. (flutter/engine#41135)
Don't use `OffscreenCanvas` in Safari, it doesn't support WebGL.
2023-04-12 23:01:25 +00:00
Jackson Gardner
0a91352f05 Include ui_web API files in sky_engine. (flutter/engine#40846)
Include `ui_web` API files in sky_engine.
2023-04-12 22:03:30 +00:00
Bernardo Ferrari
d87ae44e99 SemanticsAction / SemanticsFlag cleanup part 5 (flutter/engine#41126)
`SemanticsAction` / `SemanticsFlag` cleanup part 5
2023-04-12 20:10:05 +00:00
Jackson Gardner
28d9e0df0f Improve Wasm Debugging. (flutter/engine#41054)
Improve Wasm Debugging.
2023-04-12 00:52:04 +00:00
Jackson Gardner
4b8536c6e9 Implement shadows in the skwasm renderer. (flutter/engine#41056)
Implement shadows in the skwasm renderer.
2023-04-11 22:44:01 +00:00
htoor3
a5fdffa8c8 [web] - Move text editing nodes outside of shadowDOM, reland (flutter/engine#40968)
[web] - Move text editing nodes outside of shadowDOM, reland
2023-04-11 19:41:14 +00:00
Bernardo Ferrari
aa47305b4d SemanticsFlag/SemanticsAction cleanup (part 3) (flutter/engine#40567)
`SemanticsFlag`/`SemanticsAction` cleanup (part 3)
2023-04-10 22:32:03 +00:00
Jackson Gardner
34cfb4d663 Re-enable some wasm tests which have been fixed now. (flutter/engine#40931)
Re-enable some wasm tests which have been fixed now.
2023-04-10 20:15:52 +00:00
Jackson Gardner
439141c38d Skwasm scene (flutter/engine#40330)
Skwasm scene
2023-04-10 17:38:57 +00:00
Dan Field
e92e4daa76 Move Skia conversion utilities to own TU (flutter/engine#40997)
Move Skia conversion utilities to own TU
2023-04-10 16:46:04 +00:00
Mouad Debbar
5d30f3f043 [web] Make 'Noto Color Emoji' opt-in (flutter/engine#40990)
[web] Make 'Noto Color Emoji' opt-in
2023-04-07 16:54:22 +00:00
Dan Field
967f12d809 [Impeller] Make multi-frame image decodes work even if the GPU switch is disabled (flutter/engine#40963)
Fixes https://github.com/flutter/flutter/issues/124269

Manually verified this is safe on an iPhone 11.

We're not creating/encoding command buffers in this path so it's ok.
AFAICT the test I added would fail if we started doing that because it
doesn't provide any real command buffer interfaces. Most of the code
here is related to tests.
2023-04-06 11:40:27 -07:00
htoor3
072045aa3d Revert "[web] Move text editing nodes outside of shadowDOM - reopened" (flutter/engine#40960)
Reverts flutter/engine#40904
2023-04-05 19:47:08 -07:00
htoor3
438394f01e [web] Move text editing nodes outside of shadowDOM - reopened (flutter/engine#40904)
[web] Move text editing nodes outside of shadowDOM - reopened
2023-04-05 23:42:21 +00:00
Yegor
7231a4d15c [web] fix SkFinalizationRegistry for dart2js (attempt 4) (flutter/engine#40938)
(this is attempt 4; details below)

Remove obsolete object caches and introduce a simpler way to manage
native objects:

* Remove the unused `SynchronousSkiaObjectCache`.
* Introduce new library `native_memory.dart` that's smaller and simpler
than `skia_object_cache.dart`.
* Introduce two types of native object references:
  * `UniqueRef` a reference with a unique Dart object owner.
* `CountedRef` a ref-counted reference with multiple Dart object owners.
* All native references use GC (via `FinalizationRegistry`) as a
back-up.
* The new library removes everything related to object resurrection that
was needed only in browsers that didn't support `FinalizationRegistry`.
All browsers support it now.
* Remove the ad hoc `SkParagraph` cache that predates the introduction
of `Paragraph.dispose`.
* Rewrite `CkParagraph` in terms of `UniqueRef`.
* Rewrite `CkImage` in terms of `CountedRef`; delete `SkiaObjectBox`.

This PR does not migrate all objects from the old
`skia_object_cache.dart` to `native_memory.dart`. That would be too big
of a change. The migration can be done in multiple smaller PRs.

This also removes a few unnecessary relayouts observed in
https://github.com/flutter/flutter/issues/120921, but not all of them
(more details in
https://github.com/flutter/flutter/issues/120921#issuecomment-1481958762)

## About attempt 4

More info about the revert of attempt 3 in
https://github.com/flutter/engine/pull/40937.

In this attempt I check that the browser supports `FinalizationRegistry`
before registering the object. This will allow the code to run in older
browsers, but there will be no protection from memory leaks when the app
fails to dispose of the respective objects.

## Benchmarks

Now that this landed in flutter/flutter I have some benchmark numbers
from the devicelab. The `text_out_of_picture_bounds` benchmark dropped
by 3-4x (lower is better):

<img width="358" alt="Screenshot 2023-04-04 at 6 13 06 PM"
src="https://user-images.githubusercontent.com/211513/229956170-a5399ed3-c779-4af0-babb-ea40440f96ff.png">

The repro provided in https://github.com/flutter/flutter/issues/123204
dropped from 110ms/frame to 10ms/frame.
2023-04-05 11:08:00 -07:00
Casey Hillers
8a7ac5f702 Revert "[web] remove obsolete object caches; simplify native object management" (flutter/engine#40937)
Reverts flutter/engine#40894

This is breaking Google Testing. See b/277004090
2023-04-04 21:49:35 -07:00
Yegor
ebfd37a6f7 [web] remove obsolete object caches; simplify native object management (flutter/engine#40894)
(this is attempt 3; details below)

Remove obsolete object caches and introduce a simpler way to manage
native objects:

* Remove the unused `SynchronousSkiaObjectCache`.
* Introduce new library `native_memory.dart` that's smaller and simpler
than `skia_object_cache.dart`.
* Introduce two types of native object references:
  * `UniqueRef` a reference with a unique Dart object owner.
* `CountedRef` a ref-counted reference with multiple Dart object owners.
* All native references use GC (via `FinalizationRegistry`) as a
back-up.
* The new library removes everything related to object resurrection that
was needed only in browsers that didn't support `FinalizationRegistry`.
All browsers support it now.
* Remove the ad hoc `SkParagraph` cache that predates the introduction
of `Paragraph.dispose`.
* Rewrite `CkParagraph` in terms of `UniqueRef`.
* Rewrite `CkImage` in terms of `CountedRef`; delete `SkiaObjectBox`.

This PR does not migrate all objects from the old
`skia_object_cache.dart` to `native_memory.dart`. That would be too big
of a change. The migration can be done in multiple smaller PRs.

This also removes a few unnecessary relayouts observed in
https://github.com/flutter/flutter/issues/120921, but not all of them
(more details in
https://github.com/flutter/flutter/issues/120921#issuecomment-1481958762)

## About attempt 3

More about [attempt 2
here](https://github.com/flutter/engine/pull/40862).

In this attempt 3 I'm replacing the `factory` with a top-level function.
2023-04-04 12:43:31 -07:00
joshualitt
bee9f91790 [web] Migrate EventListener's to JS types. (flutter/engine#40566) 2023-04-04 09:53:13 -07:00
Jackson Gardner
1f7f52ffac Fail the run_suite_step if any test failures are detected. (flutter/engine#40834)
We need to throw if the `run_suite_step` encounters any test failures.
2023-04-03 18:02:31 -07:00
Chinmay Garde
51aca8ead9 [Impeller] Don't crash in image decompression if the context is unavailable. (flutter/engine#40890)
[Impeller] Don't crash in image decompression if the context is unavailable.
2023-04-03 19:49:04 +00:00
Casey Hillers
20cb8b8efc Revert "[web] remove obsolete object caches; simplify native object management" (flutter/engine#40882)
Reverts flutter/engine#40862

Google Testing is failing on

```
The compiler crashed: root:🎯_engine::SkObjectFinalizationRegistry::@methods::|staticInteropFactoryStub is already bound to Reference to dart:_engine::SkObjectFinalizationRegistry::@methods::|staticInteropFactoryStub, trying to bind to Reference to SkObjectFinalizationRegistry.|staticInteropFactoryStub with node SkObjectFinalizationRegistry.|staticInteropFactoryStub (Procedure:1207727)
```
2023-04-03 10:18:26 -07:00
Yegor
e55fd93f5f [web] remove obsolete object caches; simplify native object management (flutter/engine#40862)
[web] remove obsolete object caches; simplify native object management
2023-04-03 04:31:16 +00:00
Casey Hillers
5a226729ad Revert "[web] remove obsolete object caches; simplify native object management" (flutter/engine#40861)
Reverts flutter/engine#40617

See b/276167870. This is causing a build breakage to Google testing for
all web projects.
2023-04-01 18:55:02 -07:00
Zachary Anderson
45e3c0920f Revert "[web] Move text editing nodes outside of shadowDOM" (flutter/engine#40847)
Reverts flutter/engine#39688

Looks like this is causing the roll to the framework to fail. See
https://ci.chromium.org/ui/p/flutter/builders/try/Linux%20web_long_running_tests_4_5/34083/overview

```
00:03 +1 -1: Hello World App enable accessibility [E]

  JavaScriptException (500): javascript error: Cannot read properties of null (reading 'querySelector')
    (Session info: headless chrome=96.0.4664.0)

  package:webdriver/src/handler/w3c/utils.dart 57:9       parseW3cResponse
  package:webdriver/src/handler/w3c/core.dart 59:19       W3cCoreHandler.parseExecuteResponse
  package:webdriver/src/async/web_driver.dart 260:37      WebDriver.execute.<fn>
  package:webdriver/src/common/request_client.dart 96:32  AsyncRequestClient.send
  ===== asynchronous gap ===========================
  test_driver/smoke_web_engine_test.dart 41:40            main.<fn>.<fn>
  ===== asynchronous gap ===========================
  package:test_api/src/backend/declarer.dart 215:9        Declarer.test.<fn>.<fn>
  ===== asynchronous gap ===========================
  package:test_api/src/backend/declarer.dart 213:7        Declarer.test.<fn>
  ===== asynchronous gap ===========================
  package:test_api/src/backend/invoker.dart 258:9         Invoker._waitForOutstandingCallbacks.<fn>


00:03 +1 -1: Hello World App (tearDownAll)

```
2023-03-31 20:05:46 -07:00
Yegor
0d6952f097 Revert "[web] use callConstructor for FinalizationRegistry due to bug… (flutter/engine#40841)
… in dart2js (#40798)"

This reverts commit 5281ec18556a4775594e81f456c2a8ab785fa322.

The original PR resulted in a silent failure.
2023-03-31 18:13:12 -07:00
htoor3
c32816a82c [web] Move text editing nodes outside of shadowDOM (flutter/engine#39688)
[web] Move text editing nodes outside of shadowDOM
2023-03-31 23:13:21 +00:00
Mouad Debbar
c8039e2544 [web] Fix canvasKitVariant test (flutter/engine#40833)
[web] Fix canvasKitVariant test
2023-03-31 23:06:33 +00:00
Yegor
5281ec1855 [web] use callConstructor for FinalizationRegistry due to bug in dart2js (flutter/engine#40798)
[web] use callConstructor for FinalizationRegistry due to bug in dart2js
2023-03-31 22:48:15 +00:00
Zachary Anderson
284b13faae Revert "[macOS] Change view ID to signed" (flutter/engine#40829)
Reverts flutter/engine#39958

Failing the roll to the framework starting with
https://github.com/flutter/flutter/pull/123893

One example:
https://ci.chromium.org/ui/p/flutter/builders/try/Mac%20dart_plugin_registry_test/21819/overview
2023-03-31 13:52:57 -07:00
Tong Mu
d3bbe5cb8a [macOS] Change view ID to signed (flutter/engine#39958)
This PR makes view ID signed from unsigned int64.

Initially, I made view IDs unsigned because they were opaque anyway. As
I'm working deeper into multiview, I found some issues that made me
think signed is better:

* Unsigned integers are worse
  * Sometimes you want negative values to represent special values.
* Unsigned integers are dangerous (if compared with signed ones by
mistake.)
* Unsigned integers are not needed
  * We're very unlikely to reach that big anyway.
  * Almost all other languages support only signed integers.
  * Also JavaScript only supports up to 51 bits of integer.

Therefore I think it's better to change them to signed int64, especially
before these APIs are widely used by developers.

## 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 Hixie said 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
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[C++, Objective-C, Java style guides]:
https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
[testing the engine]:
https://github.com/flutter/flutter/wiki/Testing-the-engine
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
2023-03-31 12:11:49 -07:00
Jackson Gardner
1a59a35e3c ui_web library (flutter/engine#40608)
`ui_web` library
2023-03-30 23:14:18 +00:00
Kevin Lubick
f944e918a1 Use new SkImages namespace instead of legacy SkImage static functions (flutter/engine#40761)
Use new SkImages namespace instead of legacy SkImage static functions
2023-03-30 20:22:09 +00:00
Bernardo Ferrari
60663bccf0 SemanticsFlag/SemanticsAction enum migration (part 1) (flutter/engine#40571)
`SemanticsFlag`/`SemanticsAction` enum migration (part 1)
2023-03-30 18:32:38 +00:00
Mouad Debbar
89becd1e69 [web] LRU cache for text segmentation (flutter/engine#40782)
[web] LRU cache for text segmentation
2023-03-30 18:01:08 +00:00
Harry Terkelsen
8f9c5e83dd Switch from Noto Emoji to Noto Color Emoji and update font data (flutter/engine#40666) 2023-03-29 14:12:25 -07:00
Dan Field
340d78d20b [Impeller] Start a more generic stroke tessellator for path (flutter/engine#40690)
[Impeller] Start a more generic stroke tessellator for path
2023-03-29 06:07:05 +00:00
Yegor
7315c36b16 [web] remove obsolete object caches; simplify native object management (flutter/engine#40617)
[web] remove obsolete object caches; simplify native object management
2023-03-29 05:17:53 +00:00
Harry Terkelsen
868f1c628f Revert "Revert "[canvaskit] Use FontCollection API from CanvasKit to mitigate caching issues (#40673)" (#40705)" (flutter/engine#40740)
Reland "[canvaskit] Use FontCollection API from CanvasKit to mitigate caching issues"
2023-03-29 03:55:13 +00:00