2971 Commits

Author SHA1 Message Date
Mouad Debbar
7b3b362623 [web] Cleaner output on LUCI (flutter/engine#41989)
Using ansi colors in LUCI results in output that looks like:
```
00:00 +0: loading flutter_tester_emulation_golden_test.dart                                                                                                                                            
00:01 +0: loading flutter_tester_emulation_golden_test.dart                                                                                                                                            
00:02 +0: loading flutter_tester_emulation_golden_test.dart
```

This PR disables colors on LUCI so that we get clean output that's easily scannable and searchable.
2023-05-12 21:50:22 +00:00
Bruno Leroux
fea415faa0 [Web+Linux] Fix pressing Meta keys throws (flutter/engine#41694)
## Description

This PR fixes Meta keys throwing exception on Chrome Linux.

The assertions throws because the DOM event sent when Meta keys is pressed is not coherent when Meta is the only pressed key.

## Related Issue

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

## Tests

Adds 1 test.
2023-05-12 21:46:17 +00:00
Mouad Debbar
e87d7155d2 [web] Fix crash on old versions of Chrome (Intl.Segmenter missing) (flutter/engine#41986)
`Chrome < v87` have the `v8BreakIterator` API but don't have `Intl.Segmenter`. This caused crashes for some apps (see b/281377168).

This PR enhances our feature detection to take into account this API mismatch.
2023-05-12 19:59:30 +00:00
Kevin Lubick
0c3dbe50e1 Use moved SkImage procs (flutter/engine#41947)
Use relocated SkImages context typedefs

In http://review.skia.org/661059, we moved many SkImage related methods, including these typedefs. This updates Flutter to use the moved types.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-05-11 20:16:54 +00:00
Samuel
3b10a111f4 fix: platform_dispatcher documentation typo (flutter/engine#41739)
fixes [https://github.com/flutter/flutter/issues/126082](https://github.com/flutter/flutter/issues/126082) 

*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
2023-05-11 20:13:47 +00:00
Jackson Gardner
d03ba5aacb Return fonts in a deterministic order. (flutter/engine#41907)
We need to make sure to return fonts in the order we passed them in, so that unit tests don't flake if they load in a different order.
2023-05-11 05:13:03 +00:00
Srujan Gaddam
df4bd5d036 Turn @staticInterop tear-off into closure (flutter/engine#41885)
@staticInterop members will start disallowing tear-offs, so this member should turn into a closure.

The static check wasn't added in time, so this is modifying the source code again.

ee3ce32c7c was the original change, but the static error didn't make it into the Dart SDK, so this is fixing another tear-off.

- [] 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.
2023-05-11 00:18:14 +00:00
Mouad Debbar
9fce37c015 [web] Expose PlatformLocation and HashUrlStrategy through ui_web (flutter/engine#41163)
1. Expose `PlatformLocation` and its subclass `BrowserPlatformLocation` through the new `ui_web`.
2. Expose `HashUrlStrategy` too. It's useful for users who want to extend and customize it instead of building their own from scratch.
3. `ui_web/url_strategy.dart` => `ui_web/navigation/url_strategy.dart`.
2023-05-10 23:57:46 +00:00
Yegor
bdfce08b64 [web] generalize focusability in semantics (flutter/engine#41831)
Introduce 2 new classes for a11y focus management:

* `AccessibilityFocusManager`: a generic class that attaches "focus" and "blur" event handlers, and forwards the events to the framework as `SemanticsAction.didGainAccessibilityFocus` and `SemanticsAction.didLoseAccessibilityFocus` respectively. Provides the `changeFocus` method for the framework to move a11y focus to the target element.
* `Focusable`: a role manager that provides generic focus management functionality to `SemanticsObject`s that don't need anything special.

Rewrites focus management using the above two classes as follows:

* All focusable nodes except text fields and incrementables get the `Focusable` role (all custom focus stuff in `Tappable` was removed and delegated to `Focusable`).
* `Incrementable` uses a custom `<input>` internally and so it cannot use the `Focusable` role. Instead, it uses `AccessibilityFocusManager` to manage the focus on the `<input>` element.

Behavioral changes:

* Fixes https://github.com/flutter/flutter/issues/118737, but more generally fixes all nodes that use the `isFocusable` and `hasFocus` bits.
* `Tappable` only partially implemented focusability (e.g. it didn't generate the respective `SemanticsAction` events). Now by delegating to `Focusable`, it will inherit all the functionality.
* `Incrementable` and `Checkable` (checkboxes, radios, switches) get focus management features for the first time.
* Elements that are not inherently focusable (text, images) can now be focused if semantics requires them to be.
* `TextField` is left alone for now as focus and on-screen keyboard interact with each other in non-obvious ways.
2023-05-10 22:40:20 +00:00
Mouad Debbar
fdb4e5468d [web] Re-enable history tests on Safari (flutter/engine#41901)
Fixes https://github.com/flutter/flutter/issues/51169
2023-05-10 19:58:05 +00:00
Yegor
0e9f0ef05f [web] dialog a11y fixes (flutter/engine#41681)
Fixes two issues in dialog accessibility:

* Fixes https://github.com/flutter/flutter/issues/45207 by setting `role="dialog"` on nodes that have both `scopesRoute` and `namesRoute` set. There's no guarantee that this combination of flags is an actual dialog, but it's close enough, and it makes the screen reader announce the appearance of the dialog. Note that `scopesRoute` alone is not sufficient, because Flutter uses it for overlays that are not semantically dialogs, such as dismiss barriers.
* Fixes an issue with focus management, where focus fails to transfer to background content after the dialog is dismissed. This happened because `EngineSemanticsOwner._semanticsTree` retained descendants of parents that were removed. This is benign in many cases. However, for focus this is problematic because the HTML element can go away and come back (losing focus along the way), but its corresponding `SemanticsObject` is never marked as "dirty" and fails to update and request focus.

I'm hoping this is sufficient to fix b/251839784 as well. Will work with the relevant team to find out.
2023-05-10 05:02:22 +00:00
Jackson Gardner
3c85b2e565 Implement text rendering in Skwasm (flutter/engine#41832)
This implements full text rendering with the Skwasm renderer.

The font fallback logic has been refactored to decouple the font fallback manager from any CanvasKit-specific types and functions.

A chunk of CanvasKit text rendering tests have been ported over to the renderer-agnostic `ui` tests.

Fixes https://github.com/flutter/flutter/issues/126339
2023-05-09 23:37:21 +00:00
Jackson Gardner
5c98a397a2 Get rid of "outrageous" default text styles for HTML renderer. (flutter/engine#41822)
The CanvasKit renderer doesn't do this, so we should just remove the red text global style.
2023-05-08 22:59:21 +00:00
Jackson Gardner
16360e9e25 Reland "Skwasm Font Loading (flutter/engine#41756)
This relands https://github.com/flutter/engine/pull/41246, which had to be reverted due to some issues parsing the font manifest.
2023-05-08 18:17:22 +00:00
Michael Goderbauer
43516df2d1 Fix doc to fix engine roll (flutter/engine#41812)
The engine roll is currently failing (https://cirrus-ci.com/task/5475027185827840?logs=main#L172) because of a doc issue introduced by https://github.com/flutter/engine/pull/41685. This fixes the doc issue.
2023-05-08 10:57:19 +00:00
Dan Field
ea5131772d Add a Display API to dart:ui that reports the physical size, DPR, and refresh rate of the main display (flutter/engine#41685)
Fixes https://github.com/flutter/flutter/issues/123307 - for Android, iOS, and Web, for the main display only (https://github.com/flutter/flutter/issues/125938 tracks supporting multiple displays, https://github.com/flutter/flutter/issues/125939 for desktop).

Desktop will need to be implemented for this, but given priority for a couple of our customers targetting foldable devices on Android I'm inclined to get this in before desktop can be finished.

The main concern for this right now is that on some Android foldable devices, setting a preferred orientation will cause letterboxing and the `MediaQuery` will _never_ get the full screen size when unfolded. This causes apps to think the screen is smaller than it is, as they've mainly been using `MediaQueryData.size` to figure this out. Android's recommendation is to not set a preferred orientation, and if you must to use the new method introduced in `ViewUtil.java` to calculate the maximal window size.
2023-05-06 18:28:22 +00:00
Tong Mu
05036058d7 Remove single window assumption from SceneBuilder (flutter/engine#41559)
This PR fixes https://github.com/flutter/flutter/issues/112202. `Scene`
is no longer tied to views, but receives method arguments for view
properties, clearing the path to multiview Flutter.

`Scene` no longer creates a `LayerTree` on construction, but only part
of the config. When a output method is called (`toImage`, `toImageSync`,
or `takeLayerTree`), the `LayerTree` is constructed on the spot. In this
way, all `LayerTree`s return to being `unique_ptr`s instead of
`shared_ptr`s, reverting part of
https://github.com/flutter/engine/pull/35608 . And `Scene` no longer
needs to disfunction after one `takeLayerTree`, since the layer tree
config is never really taken away.

A `device_pixel_ratio` is now added to the parameter list of `Engine::Render` and `Animator::Render`.

## 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.
- [ ] 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.
- [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
[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-05-05 11:25:55 -07:00
Jackson Gardner
f2970b73b0 Revert "Skwasm Font Loading" (flutter/engine#41750)
Reverts flutter/engine#41246

The new font manifest parsing fails in some cases.
2023-05-04 23:54:18 +00:00
Jackson Gardner
6f5ad9737e Skwasm Font Loading (flutter/engine#41246)
This implements font loading for the skwasm renderer.

In addition, it does some pretty major refactors:
1) Simplified the font collection interface to just have a single `loadAssetFonts` call, without the separate registration and debug fonts loading stuff
2) Debug fonts load now through http/asset mocking mechanisms instead of having a separate `downloadDebugTestFonts` call
3) Consolidated a few of our different unit test setup functions into a single `setUpUnitTests` function
2023-05-04 18:22:53 +00:00
Jackson Gardner
5189eda98b Populate fallback fonts from CIPD in tests (flutter/engine#41656)
This fixes https://github.com/flutter/flutter/issues/85793

The script that generates the font fallback data also rolls a package to CIPD with these files and updates the DEPS to download those files from CIPD. This makes sure that these tests are hermetic.
2023-05-04 05:12:54 +00:00
Jonah Williams
dfff522046 Remove physical model layer (flutter/engine#41593)
Removes the physical model layer and associated engine code. This was already deprecated and removed in the framework. By removing it in the engine, we can also remove the need for layer tree diff/paint/preroll to have the device pixel ratio. This will simplify some of the multi-view work

Fixes https://github.com/flutter/flutter/issues/125720
2023-05-03 20:28:53 +00:00
Greg Spencer
18125adcfc Reland: "Determine lifecycle by looking at window focus also" (#41094) (flutter/engine#41702)
## Description

This reverts commit e49577708d9d5315fa6c001d7dc20ee80d04cd35 to re-land #41094 because the Google test failures have been fixed. There are no changes to the original PR, since the fixes were in the Google code.
2023-05-03 19:21:58 +00:00
Mouad Debbar
9ed3f6008e [web] Improve null safety for color->css (flutter/engine#41699)
Turning `colorToCssString` into an extension method on `ui.Color` improves null safety and developer ergonomics.
2023-05-03 18:15:04 +00:00
Mouad Debbar
9cb01b94d5 [web] Remove unused function parameter (flutter/engine#41700)
The `hasAutofillOverlay` and `cssSelectorPrefix` parameters aren't really used in any useful way. Let's remove them.
2023-05-03 17:57:21 +00:00
Bruno Leroux
d56b8bee57 Web - Fix selection jump on Chrome for Android (flutter/engine#41202)
## Description

This PR fixes cursor jump on Chrome for Android when the user taps in a multiline `TextField`.

Using the following code sample:

<details><summary>Code sample</summary>

```dart

import 'package:flutter/material.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      title: 'Text Field Focus',
      home: MyCustomForm(),
    );
  }
}

// Define a custom Form widget.
class MyCustomForm extends StatelessWidget {
  const MyCustomForm({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Text Field Focus'),
      ),
      backgroundColor: Colors.amber,
      body: Padding(
        padding: const EdgeInsets.all(16.0),
        child: TextField(
          decoration: const InputDecoration(
            fillColor: Colors.white,
            filled: true
          ),
          autofocus: true,
          maxLines: 3,
          controller: TextEditingController(text: '1\n2\n3\n4\n'),
        ),
      ),// This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}

```
</details>

On a mobile browser, once the page is loaded, tap after the number 3: 

- Before this PR: the TextField content is automaticaly scrolled and the selection is set after number 1.

https://user-images.githubusercontent.com/840911/232051413-b913f890-6cb1-4c60-92d0-7a3bf74cc688.mov

## Implementation

A multiline `TextField` relies on an HTML `<textarea>` elements. When a tap occurs the selection should be updated from Flutter not by the HTML element itself. 
This PR prevents mouse events on Chrome for Android. Those events conflicts with Flutter selection changes.
Previously, mouse events were only prevented on desktop but they are also emitted on mobile, see https://bugs.chromium.org/p/chromium/issues/detail?id=119216#c11.

## Related Issue

Related to https://github.com/flutter/flutter/issues/124483 (partial fix because the issue is also reproducible on iOS/Safari).

## Tests

Adds 1 test.
2023-05-02 19:34:35 +00:00
Srujan Gaddam
08ab47dddf Turn @staticInterop tear-off into closure (flutter/engine#41643)
@staticInterop members will start disallowing tear-offs, so this member
should turn into a closure.

Unblocks a roll in the SDK that disallows tear-offs.

## 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 Hixie said 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.
2023-05-01 16:18:32 -07:00
Xilai Zhang
e49577708d [flutter roll] Revert "Determine lifecycle by looking at window focus also" (flutter/engine#41626)
Reverts flutter/engine#41094.

context: updated the java/android timeouts and details in b/280204906
2023-05-01 16:46:02 +00:00
Kevin Lubick
46d1954049 Reland image encoder (flutter/engine#41632)
This is a reland of #41368 with fix for transparent images and a unit
test to verify it.

Skia would like to remove `SkImageGenerator::MakeFromEncoded` and this
appears to be the only remaining usage. It appears to be easily swapped
out for the `SkImages::DeferredFromEncodedData`. (skbug.com/13052)

This also removes the use of the internal `SkCodecImageGenerator` for
the public `SkCodec` API (which the image generator had just been
deferring to anyway).

While unbreaking some unit tests, I made a few assertions easier to
debug and produce nicer error messages.

## 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 Hixie said 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].
- [ ] 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-05-01 07:33:23 -07:00
Loïc Sharma
b786d923f5 Remove single view assumption from pointer events (flutter/engine#41602)
This change removes the assumption that that all pointer events go to the view ID `0`. This change also adds a test for pointer events.

Part of: https://github.com/flutter/flutter/issues/112205

## Background

All pointer events are sent to [`PlatformDispatcher.onPointerDataPacket`](https://api.flutter.dev/flutter/dart-ui/PlatformDispatcher/onPointerDataPacket.html). In the future, a `viewId` property will be added [`PointerData`](https://api.flutter.dev/flutter/dart-ui/PointerData-class.html), which the framework (specifically, `GestureBinding`) will use to route the event to the proper view. This `viewId` property's value will be set by the embedders.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-04-29 03:47:10 +00:00
Zachary Anderson
4eae6e1164 Revert "Replace deprecated and internal Skia EncodedImage calls with public versions" (flutter/engine#41595)
Reverts flutter/engine#41368

This is blocking rolls into the framework. Let's revert until we sort
out whether there's a workaround for the change to the unpremultiplied
alpha issue.
2023-04-28 13:41:00 -07:00
Greg Spencer
962cbf0a22 Determine lifecycle by looking at window focus also (flutter/engine#41094)
## Description

This incorporates additional signal from `Activity.onWindowFocusChanged` to help decide if the application is `resumed` or `inactive`.

When the user pulls down the notification shade or opens the app switcher in iOS, then iOS sends a notification to the application that it no longer has input focus (is no longer "active" in Apple terminology). 

However, Android (at least on a Pixel) doesn't send `onPause` and `onResume` events for these things, as one might expect. Instead, this PR changes things so that we listen to `Activity.onWindowFocusChanged` and see if any of the windows still have focus.

If it doesn't have focus, then the lifecycle switches to `inactive` (even if `onPause` hasn't been called), and if it does have focus (and `onResume` hasn't been called) then we should go to `resumed`.

State changes are determined and deduped in the `LifecycleChannel` class.

Here's the old state table:

| Android State | Flutter state |
| ------------- | ------------- |
| Resumed  | resumed |
| Paused  | inactive |
| Stopped | paused |
| Detached | detached |

Here's the new state table:

| Android State | Window focused | Flutter state |
| ------------- | ------------- | ------------- |
| Resumed  | true  | resumed |
| Resumed  | false  | _inactive_ * |
| Paused  | true  | inactive |
| Paused  | false  | inactive |
| Stopped  | true  | paused |
| Stopped | false  | paused |
| Detached | true  | detached |
| Detached | false  | detached |

* = This is the relevant change in this PR.

("Window focused" means one or more windows managed by Flutter are focused)

The `inactive` state is for when the application is running and visible, but doesn't have the input focus.  An example where this currently happens are when a phone call is in progress on top of the app, or on some OEMs when going into the app switcher (I've tested on Realme and it does that, at least).  With the PR, it will also go into `inactive` when the app has lost input focus, but is still in the Android `onResume` state. This means that on phones that don't pause the app when they go into the app switcher or the notification window shade (Pixel, others), the app will go into `inactive` when it didn't before. If developers weren't doing anything special in the `inactive` state before, then this PR will have no change for them. If they were, they will go into that state more often (but more consistently across OEMs).

## Related Issues

  - Fixes  https://github.com/flutter/flutter/issues/124591

## Tests

  - Added unit tests for handling `onWindowFocusChanged`.
2023-04-28 17:43:36 +00:00
Kevin Lubick
76896edd18 Replace deprecated and internal Skia EncodedImage calls with public versions (flutter/engine#41368)
Skia would like to remove `SkImageGenerator::MakeFromEncoded` and this
appears to be the only remaining usage. It appears to be easily swapped
out for the `SkImages::DeferredFromEncodedData`. (skbug.com/13052)

This also removes the use of the internal `SkCodecImageGenerator` for
the public `SkCodec` API (which the image generator had just been
deferring to anyway).

While unbreaking some unit tests, I made a few assertions easier to
debug and produce nicer error messages.
2023-04-28 09:10:33 -07:00
Srujan Gaddam
e253aeff60 Remove package:js references and move to dart:js_interop (flutter/engine#41212)
dart:js_interop and package:js will start conflicting. Eventually, we
want people to only use dart:js_interop, so this CL refactors code to do
that.

Unblocks https://dart-review.googlesource.com/c/sdk/+/294130/8 and
prevents confusing shadowing of dart:js_interop annotations like we do
today.

## 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], including [Features
we expect every widget to implement].
- [X] I signed the [CLA].
- [Mentioned CL that is unblocked] I listed at least one issue that this
PR fixes in the description above.
- [X] I updated/added relevant documentation (doc comments with `///`).
- [Need test-exemption] I added new tests to check the change I am
making, or this PR is [test-exempt].
- [X] All existing and new tests are passing.
2023-04-25 12:20:12 -07:00
Jason Simmons
6f5ee7f984 [Impeller] Add a CommandBuffer::WaitUntilScheduled API (flutter/engine#41303)
This can be used by IO thread operations such as image decoding to ensure that the results of GPU commands become visible to the raster thread.
2023-04-21 19:08:04 +00:00
David Iglesias
dfd9ef5e60 [web] Fix HashUrlStrategy.addPopStateListener (flutter/engine#41384)
During a JS-interop refactor, we introduced a small bug in the `addPopStateListener` method of the `HashUrlStrategy` object (web).

This wasn't caught before because the existing tests were mocking the refactored code.

## Issues

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

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-04-21 17:26:31 +00:00
maRci002
da6f9f69f2 [web] change status bar color based on SystemUiOverlayStyle (flutter/engine#40599)
Closes flutter/flutter#123365

In my [example code](https://github.com/flutter/flutter/issues/123365#issue-1638490447) I'm using `SystemUiOverlayStyle.dark` which has `null` `statusBarColor` by default (_which can be changed via `Change status bar color` button_) in this case we do not override browser's default status bar color.

| Old behaviour | New behaviour |
| -- | -- |
| <video src="https://user-images.githubusercontent.com/8436039/227386349-e30cce47-ffc6-4465-bb30-cd2888f77d32.mp4" /> | <video src="https://user-images.githubusercontent.com/8436039/227580430-a25e57dc-9d5a-43a1-bcb3-3bd8abd753d8.mp4" /> |

In case of PWA the when `statusBarColor` is `null` it will use `theme_color` property from `manifest.json` (I don't know from where does flutter generate `manifest.json`).

The default status bar color for PWA is: `"theme_color": "#0175C2",`
f4caee6efb/examples/api/web/manifest.json (L7)

| Old PWA behaviour | New PWA behaviour |
| -- | -- |
| <video src="https://user-images.githubusercontent.com/8436039/227607373-79be7294-d9f7-4a45-9014-28720acce0c7.mp4" /> | <video src="https://user-images.githubusercontent.com/8436039/227607329-be16131f-4104-419a-8e16-2b229d73d95e.mp4" /> |

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-04-20 14:33:07 +00:00
Brandon DeRosier
b4271c24de Add missing header guards (flutter/engine#41322)
These keep turning up, so I did a little bash-fu to find them all.
```bash
grep -lL "#pragma once" $(grep -lL "#ifndef .*_H_" $(find . | grep "\.h$")) | cut -c 3-
```
2023-04-19 21:20:21 +00:00
joshualitt
90138c2003 [web] Fix trivial type issue. (flutter/engine#40956) 2023-04-19 12:58:30 -07:00
Chinmay Garde
4117cb927e [Impeller] Make //impeller/display_list TU naming consistent. (flutter/engine#41174)
No change in functionality. I've just renamed the TU's to replace `display_list_` to `dl_`. I am sure there are chances to make the naming better. For instance, the op receiver still being named a dispatcher.
2023-04-19 17:32:53 +00:00
Mouad Debbar
2bc352f431 [web] Remove non-ShadowDom mode (flutter/engine#39915)
If we still want to do this, here's a quick PR :)

Fixes https://github.com/flutter/flutter/issues/116204
2023-04-19 16:15:21 +00:00
Yegor
d5474b17ac [web:canvaskit] remove unnecessary instrumentation from picture (flutter/engine#41313)
Remove unnecessary instrumentation from picture. `UniqueRef`
automatically instruments all allocations, disposals, and garbage
collections, which covers `CkPicture`.
2023-04-18 16:49:00 -07:00
Yegor
1289bfa247 [web:canvaskit] clean up the rest of skia_object_cache usages (flutter/engine#41259)
This should go after https://github.com/flutter/engine/pull/41230.

Removes the remaining usages of `skia_object_cache.dart` and deletes it.

Also fixes https://github.com/flutter/flutter/issues/86632
2023-04-18 14:34:01 -07:00
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