6403 Commits

Author SHA1 Message Date
Jim Graham
e0392194d3
[Impeller] Migrate unit tests off of Skia geometry classes (#161855)
Handles the impeller unittests line in
https://github.com/flutter/flutter/issues/161456

This PR is focused on the unit tests in Impeller. There are still some
uses in other non-test areas which will be handled in a separate PR.
2025-01-22 20:27:06 +00:00
Robert Ancell
2d3beadffe
Move FlKeyboardManager and FlKeyboardHandler from FlView to FlEngine. (#161925)
There can only be one handler that is shared between the views.

Move event redispatch matcher back into FlKeyboardManager - if a
redispatched event was moved between views due to a focus change it
would not be matched against.
2025-01-22 20:07:11 +00:00
Robert Ancell
e53bd2a103
Remove FlKeyboardViewDelegate (#161705)
Instead, do the filtering at the point the event is redispatched.
2025-01-21 23:18:20 +00:00
Robert Ancell
f2ce662fd2
Refactor event redispatching (#161701)
Instead of doing the redispatching from inside FlKeyboardManager, return
the event asynchronously to the code that provided the event in the
first case. That code has all the context on how to do the redispatch -
this will be more complicated in a multi-view case.
2025-01-17 01:01:49 +00:00
Robert Ancell
a6045c9985
Make fl_keyboard_manager_handle_event async (#161637)
In this way we can tell when this call completes, which should help
testing and refactoring.
2025-01-16 23:45:48 +00:00
Robert Ancell
732e003745
Remove some stray printf debugging (#161706) 2025-01-16 22:47:02 +00:00
Jonah Williams
90f926edc1
[Impeller] Update partial repaint to use a fullsize onscreen. (#161626)
The existing technique of offsetting a smaller texture is very vunerable
to bugs in the renderer. Rather than this approach, we can allocate a
new offscreen that is full sized and then blit a smaller region. To
reduce the allocation costs, we can also set up a transients cache which
will reuse this texture. In total, this should be more performant than
the existing partial repaint (due to lack of continual re-allocation) at
the cost of higher peak memory usage.

Fixes https://github.com/flutter/flutter/issues/140877
Fixes https://github.com/flutter/flutter/issues/160588
Fixes https://github.com/flutter/flutter/issues/156113
2025-01-16 19:29:36 +00:00
Jim Graham
a10e25e727
[DisplayList] Migrate from SkRSXform to Impeller RSTransform (#161652)
Fixes SkRSXform task in https://github.com/flutter/flutter/issues/161456

Removes (nearly) all uses of Skia SkRSXform object from DisplayList and
replaces it with a new Impeller RSTransform geometry object.

There are remaining uses in:
- Skia adapter code which needs to convert them back to SkRSXform when
using the Skia backend
- dl_rendering_tests which is waiting for a major conversion effort
- ?Fuchsia? code has an SkCanvas spy adapter used in its embedder code
(not DisplayList related)
- web_ui/skwasm
2025-01-15 19:08:38 +00:00
NabilaWorks
e0d7b588b6
Feature/twitter keyboard (#161025)
<!--
Thanks for filing a pull request!
Reviewers are typically assigned within a week of filing a request.
To learn more about code review, see our documentation on Tree Hygiene:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
-->

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

Example :

```dart
import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Centered TextField Example',
      theme: ThemeData(primarySwatch: Colors.blue),
      home: CenteredTextFieldScreen(),
    );
  }
}

class CenteredTextFieldScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('Centered TextField')),
      body: Center(
        child: Padding(
          padding: const EdgeInsets.all(16.0),
          child: TextField(
            keyboardType: TextInputType.twitter,
            decoration: InputDecoration(
              border: OutlineInputBorder(),
              hintText: 'Enter some text here',
            ),
          ),
        ),
      ),
    );
  }
}
```


https://github.com/user-attachments/assets/5a2a2a4a-6994-44b1-bb0e-395c24012ef8


https://github.com/user-attachments/assets/aefc7bc5-a997-4e0f-a74e-a39a4517c898

## 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].
- [X] I listed at least one issue that this PR fixes in the description
above.
- [X] I updated/added relevant documentation (doc comments with `///`).
- [X] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [X] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [ ] 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/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md

---------

Co-authored-by: Jenn Magder <magder@google.com>
2025-01-15 00:15:15 +00:00
jesswrd
d8322207df
Fixed XiaoMi statusBar Bug (#161271)
Updated usages of statusBar() to systemBar() to fix XiaoMi statusBar
bug.

Fixes #132831 

## 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].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [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/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
2025-01-15 00:12:58 +00:00
Robert Ancell
c9923ca609
Remove unused method (#161572) 2025-01-14 14:35:36 +00:00
Harlen Batagelo
f2c15f9deb
Fix crash when closing a window with Alt+F4 in multi-win Flutter on Windows (#161375)
Reopened from https://github.com/flutter/engine/pull/56501.

Fixes [#158450](https://github.com/flutter/flutter/issues/158450).

As mentioned in
[#158450](https://github.com/flutter/flutter/issues/158450), the crash
occurs because a destroyed object may be accessed if the window and view
have already been destroyed by the time `KeyEventCallback` is called.
This issue is not limited to the `Alt+F4` system key; it may also occur
if the window is closed using other key presses, such as pressing
`Enter` after navigating to a dialog's "Close" button.

This PR proposes a fix that checks whether the view ID is still valid
when the callback is invoked. If the view is invalid, the event is
skipped for that view.

A unit test has been added to assert that the `KeyEventCallback` is
invoked when the associated view is valid and not invoked when the view
is destroyed.

## 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].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [ ] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [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/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
2025-01-14 13:32:36 +00:00
Jim Graham
d80be471dd
Migrate DisplayList unit tests to DL/Impeller geometry classes (#161453)
Address the first item in
https://github.com/flutter/flutter/issues/161456 (Unit tests in the
display_list/ directory)

Some new `DlPath::Make<Shape>` factories were added to make test writing
simpler.

`DlPath` is now bi-directional! You can construct one from either an
`SkPath` or an `impeller::Path` and it will auto-convert to the other as
needed. This allows unit tests with custom paths to rely on
`impeller::Path` for path construction instead of `SkPath` (as long as
only simple move/line/quad/curve verbs are needed).

`RoundRect` now normalizes the argument rect in all constructors to
match Flutter expectations and `SkRRect` legacy behavior. This behavior
was already being enforced in `ui.rrect` but the unit tests we have to
verify the behavior are written against the `RoundRect` object itself so
this was the simplest way to make the unit tests work right, while
ensuring that we maintain correct behavior for `ui` objects. Ideally
these issues would be tested at the `ui` native interface instead of as
unit tests on our internal objects and we should be allowed to decide
how we want our internal APIs to behave with regard to this concept.

Skia inverted path types are no longer allowed in `DlPath` and all use
of them should be eliminated in the engine (except to test if they crash
when used in a debug unit test)

A couple of unit tests for `DlOpSpy` and Impeller's interop package were
migrated here along for the ride even though this PR was focused
primarily on `display_list/` unit tests.
2025-01-13 19:28:57 +00:00
Robert Ancell
d14140f854
Provide monitor information. (#161359)
Fixes https://github.com/flutter/flutter/issues/144230
2025-01-12 21:20:40 +00:00
Jonah Williams
96dffbeda5
[Impeller] fix scaling of trampoline import of GLES textures into Vulkan. (#161331)
Not sure if this just needs the dpr transform or the entire canvas
transform.

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

## Before


![flutter_04](https://github.com/user-attachments/assets/be60b1d0-4e94-491c-b1da-a03d66897f12)


## After


![flutter_03](https://github.com/user-attachments/assets/64cca8b7-3ae7-4f40-af26-ae61d9ec6290)
2025-01-09 20:39:29 +00:00
Jonah Williams
6bda88b61b
[Impeller] add opt in flag for SurfaceControl testing. (#161353)
Adds an opt in flag for the Android surface control based swapchain.
This is off by default, but added for the sake of bug reports and
investigation of the functionality.
2025-01-09 16:09:41 +00:00
Robert Ancell
67f24bebe1
Refactor keyboard manager tests (#160637)
Carefully refactored FlKeyboardManager tests to make them more
consistent with existing tests in preparation for future changes to this
class.
2025-01-09 04:24:19 +00:00
Robert Ancell
94c4d0568e
Allow async platform responses in FlMockBinaryMessenger (#160636)
To help simplify the keyboard tests.
2025-01-07 21:48:44 +00:00
Matan Lurey
9467677fef
Change timing of onSurfaceDestroyed to match onSurfaceCleanup (#161252)
Follow-up to https://github.com/flutter/flutter/pull/160937
(https://github.com/flutter/flutter/issues/160933).

This more or less mirrors what we did already for `onSurfaceCreated` to
match `onSurfaceAvailable`.

With this approach, the master branch should immediately start seeing
better behavior in terms of being able to use the `onSurfaceDestroyed`
callback effectively (before the surface has been released). For
example, for a plugin that already uses `onSurfaceDestroyed`, [i.e
`camerax`](97ce56a68e/packages/camera/camera_android_camerax/android/src/main/java/io/flutter/plugins/camerax/PreviewHostApiImpl.java):

```java
@Override
public void onSurfaceDestroyed() {
  // Invalidate the SurfaceRequest so that CameraX knows to to make a new request
  // for a surface.
  request.invalidate();
}
```

... the request is now invalidated _before_ the surface has been
destroyed, which is what (I believe) we wanted?

---

Folks that want to publish package updates that _definitely_ use the
correct timing will have to wait for the next stable.

/cc @hasali19 would be great to get your input here.
2025-01-07 21:15:09 +00:00
Jonah Williams
ffc7ced2a0
[Impeller] protect onscreen cmd buffer with render ready semaphore. (#161140)
Ensures that the onscreen command buffer is blocked via the render ready
semaphore, instead of just the layout transition. I can confirm this
fixes the rendering artifacts on the Samsung a50 - which I suspect are
the same as the issues these other devices are having. Essentially,
without the semaphore protecting the onscreen pass we can end up writing
to the color attachment while it is still being read.

* https://github.com/flutter/flutter/issues/160522
* https://github.com/flutter/flutter/issues/160370
2025-01-06 20:26:08 +00:00
Matan Lurey
351f2742af
Add SurfaceProducer.onSurfaceCleanup, deprecate onSurfaceDestroyed. (#160937)
Closes https://github.com/flutter/flutter/issues/160933.

The timing of this callback gives our users (and plugin authors) a
chance to stop using the `Surface` before it becomes invalid, allowing
us to fix https://github.com/flutter/flutter/issues/156488 - we no
longer need to do shenanigans on storing and restoring state because
`ExoPlayer` can now handle it out of the box; see
https://github.com/flutter/flutter/issues/160933#issuecomment-2564092567.

It's unfortunate we have to go through a bit of churn on the callback
API, but realistically this _is_ the feedback we were looking for when
originally creating it - it just took longer than expected due to the
long release cycle.

/cc @hasali19, @xxoo, @camsim99
2025-01-06 18:03:11 +00:00
Matan Lurey
0ffc4ce00e
Remove --template=skeleton and add a placeholder error message instead. (#160695)
Closes https://github.com/flutter/flutter/issues/160673.

Does the following:

- Renames `FlutterProjectType` to `FlutterTemplateType`; did some
enhanced enum cleanups while at it
- Creates a hierarchy of `RemovedFlutterTemplateType` from
`ParsedFlutterTemplateType`
- Removes the `skeleton` directory
- Merges `app_shared` back into `app` (no longer required now that
`skeleton` is removed)

Final cleanups are tracked in
https://github.com/flutter/flutter/issues/160692.

(Added @zanderso just to spot check this is what he meant by
https://github.com/flutter/flutter/issues/160673#issuecomment-2557742347)
2024-12-24 00:02:29 +00:00
Jonah Williams
2d811593db
[Impeller] Fix GLES SurfaceTexture rendering. (#160634)
Fixes https://github.com/flutter/flutter/issues/160480

Both The Impeller and Skia variant of the OES texture rendering use the
same shared code path, so the Impeller code must match the weird 1x1
texture behavior of Skia. In addition, we have to add back the
TiledTextureContents support, since we need to render a texture with a
transform. I had previously tested this but neglected to force the
SurfaceTexture path, so I only tested the ImageReader path which does
not use a transform.
2024-12-20 19:44:19 +00:00
Jonah Williams
cec8f1035e
[Impeller] remove unused BliPass::EncodeCommands arg and cleanup. (#160623)
The TransientsAllocator argument to BlitPass::EncodeCommands is
completely unused. Delete it (and add a missing IFDEF around the GLES
debug labels.).
2024-12-20 18:02:17 +00:00
Jim Graham
a513498487
[DisplayList] Migrate DlVertices onto Impeller/DisplayList geometry classes (#160633)
DlVertices was already half migrated onto the DL geometry classes, this
completes the conversion.
2024-12-20 07:01:52 +00:00
Robert Ancell
dd058ffa5b
Remove all remaining use of mock engine (#160635)
Test consistency achieved.
2024-12-20 03:48:39 +00:00
Michael Goderbauer
8e0993eda8
Auto-format Dart code in engine (#160576)
This auto-formats all *.dart files in the `engine` subdirectory and
enforces that these files stay formatted with a presubmit check.
2024-12-19 17:13:07 +00:00
John McDole
721b47e7e6 Merge flutter/engine into framework
Adds files from flutter/flaux which contain modifications for the engine
structure. The history for engine/ has been edited. Please see
flutter/engine for the original PRs.
2024-12-17 14:00:52 -08:00
Hannes Winkler
7f8da94c21 embedder: fix bit-order in software pixel format description (flutter/engine#57156)
The order of the components for packed software pixel formats is incorrectly documented as being the order in the native type, least-significant-bit first. In reality it's the other way around. For example, for `RGB565`, the `R` is the 5 most significant bits in the 2-byte pixel value, rather than the least significant bits. The test even verify it is that way:

https://github.com/flutter/engine/blob/main/shell/platform/embedder/tests/embedder_unittests.cc#L2782-L2785

I assume noone used the software pixel formats until @sodiboo did, that's why it's gone unnoticed for so long.

Also contains some other minor documentation improvements.

- Issue: https://github.com/flutter/flutter/issues/160149

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-12-17 18:09:06 +00:00
Robert Ancell
90c1f8ca69 Migrate FlBinaryMessenger using embedder API instead of mock engine. (flutter/engine#57214)
This allows us to remove most of the remaining mock engine code.
2024-12-16 20:02:45 +00:00
MyriadSoft
475d981108 docs: Fix RGB565 format documentation and bit masks (flutter/engine#57210)
The RGB565 format documentation in embedder.h incorrectly stated that the red component uses the least significant bits. Unit tests in embedder/testdefs/embedder_unittests.cc demonstrate this is incorrect, showing:

- Red test (0xF800): Uses bits [15:11]
- Green test (0x07E0): Uses bits [10:5]
- Blue test (0x001F): Uses bits [4:0]

This commit fixes the documentation to correctly reflect the actual bit layout:
- Red uses 5 MSBs [15:11]
- Green uses 6 middle bits [10:5]
- Blue uses 5 LSBs [4:0]

Also fixes the example bit extraction code to use correct masks, matching the test expectations.

Impact: This change helps prevent potential developer confusion about RGB565 bit ordering and ensures the documentation matches the actual implementation as verified by the test suite.
2024-12-16 18:48:04 +00:00
Robert Ancell
eb4af9071e Migrate FlEventChannel tests to FlMockBinaryMessenger (flutter/engine#57150)
Use FlMockBinaryMessenger instead of mocking the whole engine.
2024-12-16 11:45:17 +13:00
Robert Ancell
dcd093fad7 Migrate FlMethodChannel tests to FlMockBinaryMessenger (flutter/engine#57146)
Use FlMockBinaryMessenger instead of mocking the whole engine.
2024-12-16 10:34:14 +13:00
Michael Goderbauer
a0eb1bc42c Fix include path in fuchsia's analysis_options.yaml files (flutter/engine#57203)
The old path doesn't exist.

`dart format` stumbles over this non-existent include.

`analysis_options.yaml` files that just imported something non-existent were deleted.

I am surprised that this never caused any other issues. Is this all dead code that isn't actually analyzed?
2024-12-14 00:51:47 +00:00
hellohuanlin
e2970df999 [ios]limit web view not tappable workaround to a limited depth (flutter/engine#57193)
This PR limits the search depth, because we don't want to enable this workaround for AdMob banner, which has a WKWebView in the depth of 7. See the previous PR for more context: https://github.com/flutter/engine/pull/57168

I was able to confirm that this returns YES for the 3P plugin, and NO for AdMob. 

*List which issues are fixed by this PR. You must list at least one issue.*
https://github.com/flutter/flutter/issues/158961

*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-12-13 19:25:25 +00:00
Jim Graham
c1b3709bdd Migrate DlRTree and DlRegion to DisplayList/Impeller geometry classes (flutter/engine#57175)
Continuing the migration of engine code to the new geometry classes. Only DlRTree and DlRegion are converted in this pass, plus a small amount of associated code.
2024-12-13 04:33:17 +00:00
hellohuanlin
f9125dfd91 [ios]enable the webview non tappable workaround by checking subviews recursively (flutter/engine#57168)
The original workaround ([PR](https://github.com/flutter/engine/pull/56804)) works for the official web view plugin, but it doesn't work for a third party plugin `flutter_inappwebview` ([issue](https://github.com/pichillilorenzo/flutter_inappwebview)). Upon discussion with the author of that plugin, it turns out that their platform view is not a WKWebView, but rather a wrapper of WKWebView. 

This PR performs a DFS search of the view hierarchy, and enable the workaround as long as there's a WKWebView inside. 

TODO: pending sample project:
I am quite positive that it should work, but **I haven't tried it since I don't have a sample project yet**. I have requested a sample project with them so I can verify the solution. 

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

 https://github.com/pichillilorenzo/flutter_inappwebview/issues/2415

*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-12-13 01:06:45 +00:00
gaaclarke
3d8fc3c652 removed c style casts and enabled the lint (flutter/engine#57162)
test exempt: should have no functional change

## 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/blob/master/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/master/docs/contributing/Style-guide-for-Flutter-repo.md
[C++, Objective-C, Java style guides]:
https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
[testing the engine]:
https://github.com/flutter/engine/blob/main/docs/testing/Testing-the-engine.md
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/master/docs/contributing/Chat.md
2024-12-12 15:33:37 -08:00
Robert Ancell
d9cdbeebea Make fl_engine_send_key_event into a standard async function. (flutter/engine#57112)
Add missing tests for this function.

Note this makes FlKeyboardManager a bit more complex, but this is
planned to be simplified in a future refactor.
2024-12-13 09:21:00 +13:00
Robert Ancell
50a40b310e Migrate FlPlatformChannel tests to FlMockBinaryMessenger (flutter/engine#57140)
Use FlMockBinaryMessenger instead of mocking the whole engine.
2024-12-13 08:40:13 +13:00
Robert Ancell
3a54460518 Migrate FlBasicMessageChannel tests to FlMockBinaryMessenger (flutter/engine#57115)
Use FlMockBinaryMessenger instead of mocking the whole engine.
2024-12-13 08:38:53 +13:00
Jim Graham
9af7a2a64d Migrate layers and layer_tree to DisplayList/Impeller geometry classes (flutter/engine#57153)
Migrates Layers and LayerTree and parts of the `flow/` utility classes to use DlGeometry (Impeller) classes.
2024-12-12 19:30:55 +00:00
Chris Bracken
e9965b2d07 iOS: Reduce engine/view controller coupling (flutter/engine#57151)
Eliminates some cases where `FlutterViewController` was relying on `FlutterEngine` internals:
* `[FlutterEngine shell]`
* `[FlutterEngine platformView]`
* `[FlutterEngine iosPlatformView]`

Instead, `FlutterEngine` now exposes:
* `installFirstFrameCallback:`
* `enableSemantics:withFlags:`
* `notifyViewCreated`
* `notifyViewDestroyed`
* `waitForFirstFrameSync:callback:`

Also fixes a couple cases where we were relying on transitive header includes:
* `FlutterAppController` relied on `FlutterViewController_Internal.h` for `sendDeepLinkToFramework:completionHandler:`

This is a refactoring followup to https://github.com/flutter/engine/pull/57099 that introduces no semantic changes.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-12-12 18:38:07 +00:00
Bryan Oltman
4eb0bd7d98 Cast ::GetLastError to int (flutter/engine#57113)
`GetLastError` returns an unsigned 32 bit integer that was being
implicitly cast to an int for the std::variant<..., int>. This was
causing my build to fail with:

```
../../flutter/shell/platform/windows/platform_handler.cc(178,12): error: no viable conversion from returned value of type 'DWORD' (aka 'unsigned long') to function return type 'std::variant<std::wstring, int>' (aka 'variant<basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t>>, int>')
  178 |     return ::GetLastError();
      |            ^~~~~~~~~~~~~~~~
../../../../../../../Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.42.34433/include\variant(923,7): note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'DWORD' (aka 'unsigned long') to 'const variant<basic_string<wchar_t>, int> &' for 1st argument
  923 | class variant : private _SMF_control<_Variant_destroy_layer<_Types...>, _Types...> { // discriminated union
      |       ^~~~~~~
```

Commands:

```
 ./flutter/tools/gn --runtime-mode release --no-rbe
ninja -C .\out\host_release windows gen_snapshot flutter/build/archives:windows_flutter
```

Explicitly casting `::GetLastError` to an int fixes this issue.

I'm running on Windows 11 (Version 10.0.26100 Build 26100) with VS 2022
Community Edition.

@loic-sharma

Co-authored-by: Eric Seidel <eric@shorebird.dev>
2024-12-11 17:23:11 -08:00
Balint Rozgonyi
41009bcda1 [Linux] Add Multi-Touch Support for Linux (flutter/engine#54214)
This draft PR aims to address the lack of multi-touch support under Linux, leveraging the existing implementation used for Windows. As I am not an expert in this domain, I would greatly appreciate feedback on the implementation.

https://github.com/flutter/flutter/issues/133239
https://github.com/flutter/flutter/issues/52202

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-12-11 22:05:04 +00:00
Jonah Williams
f8a0105146 [engine] changes to DlVertices::Builder and Stopwatch visualizer. (flutter/engine#57031)
Collection of changes to DlVertices::Builder and the stopwatch visualizer.

At a high level:

* improve performance of the stopwatch visualizer by pre-allocating storage (and sharing it across both visualizers), lookup up font once, and cache the debug frame rate used. Updates to use Dl types instead of SkTypes.

* Change DlVerticesBuilder to allow storing the bounds and use that in the visualizer, since we already know them. Make FML_CHECKS into dchecks, as the dart:ui vertices will already bounds check correctly - so these should only be necessary for debugging engine changes.
2024-12-11 21:03:06 +00:00
Robert Ancell
85b89155d5 Clean up key embedder responder tests (flutter/engine#57054)
Remove global variable.
Rename function so doesn't look like provided by GLib.
Use g_autoptr to remove explicit unref.
Move type definition inline.
2024-12-11 10:58:22 +13:00
Chris Bracken
721eec4d5b iOS: Add null checks on shell dereference (flutter/engine#57099)
`FlutterEngine` at the `_shell` unique_ptr ivar it owns have different lifetimes. `_shell` is initialised transitively from `runWithEntrypoint`, and reset in `[FlutterEngine destroyContext]`, which is called transitively from `[FlutterviewController dealloc]` via `[FlutterEngine notifyViewControllerDeallocated]`.

As such, all uses of `_shell` should be checked either via an assertion, in cases we know the shell should be non-null, or via a runtime null check in cases where it's expected that it may be null.

Specifically, this guards against a crash that can occur if we get a CoreAnimation transaction commit callback for an inflight frame just as we're shutting down the app (or removing the FlutterView in an add-to-app scenario).

Example stack trace:
```
0  Flutter                        0x11b28 -[FlutterEngine platformView] + 53 (weak_ptr.h:53)
1  Flutter                        0x11994 -[FlutterEngine updateViewportMetrics:] + 186 (ref_ptr.h:186)
2  Flutter                        0x1f854 -[FlutterViewController updateViewportMetricsIfNeeded] + 427 (vector:427)
3  Flutter                        0x1f9b8 -[FlutterViewController viewDidLayoutSubviews] + 1411 (FlutterViewController.mm:1411)
4  UIKitCore                      0x8c864 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2376
5  QuartzCore                     0x1fa0c CA::Layer::layout_if_needed(CA::Transaction*) + 516
6  QuartzCore                     0x1ae84c CA::Context::commit_transaction(CA::Transaction*, double, double*) + 516
7  QuartzCore                     0x2888 CA::Transaction::commit() + 648
```

Issue: https://github.com/flutter/flutter/issues/98735
Issue: https://github.com/flutter/flutter/issues/159639

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-12-10 19:06:13 +00:00
Brandon Castellano
9d726bb38e [engine] Migrate fuchsia.io Open functions to Open3 (flutter/engine#56818)
Migrate the use of fuchsia.io open functions to the new open3 replacements (which also requires transitioning from OpenFlags -> Flags). Likewise, we update all uses of the SDK VFS library to use the new set of flags.

This work is being done as part of the ongoing io2 migration in https://fxbug.dev/378924259

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-12-10 19:02:01 +00:00
Robert Ancell
f3c1d7bab8 Make fl_key_channel_responder_handle_event async (flutter/engine#56959)
Replace a callback with a more standard async call
2024-12-10 09:06:22 +13:00