208 Commits

Author SHA1 Message Date
Michael Klimushyn
791c5441a5 Revert "Turn on RasterCache based on view hierarchy (#13360)" (flutter/engine#13442)
This caused EmbedderTest.VerifyB143464703 to fail after merging into
master.

```
../../flutter/shell/platform/embedder/tests/embedder_unittests.cc:3111: Failure
Value of: ImageMatchesFixture("verifyb143464703.png", renderered_scene)
  Actual: false
Expected: true
[  FAILED  ] EmbedderTest.VerifyB143464703 (2507 ms)
```

This reverts commit b1479f8e6075ef95d6b11a03e318bff72a2c0288.
2019-10-30 11:25:29 -07:00
Michael Klimushyn
b1479f8e60 Turn on RasterCache based on view hierarchy (flutter/engine#13360)
Previously the cache was disabled on whether or not PlatformViews were
globally enabled. Instead track their existence in the view hierarchy
and only disable RasterCache if a PlatformView is actually present.
2019-10-30 10:45:15 -07:00
Dan Field
46bf911c59 Set the install name at link time for darwin dylibs (flutter/engine#13428) 2019-10-29 20:30:13 -07:00
Chinmay Garde
62f76d4eb8 Make sure root surface transformations survive resetting the matrix directly in Flow. (flutter/engine#13405)
This used to only be handled correctly for non-root layer backing stores. This
was mostly a side effect of the fact that we used recording canvases instead of
rendering directly into the backing store. We now use recording canvases
consistently.

Fixes b/143464703
Fixes https://github.com/flutter/flutter/issues/43732
2019-10-29 17:44:57 -07:00
Jason Simmons
2c61d2336b Reformat BUILD.gn files to comply with the format checker presubmit script (flutter/engine#13401) 2019-10-29 09:49:16 -07:00
Chris Bracken
4835f63736 Expose platform view ID on embedder semantics node (flutter/engine#13345)
This exposes platform_view_id on the embedder API's FlutterSemanticNode.

In 40e0467f60dd2174af5b3edf8bd2752eb6251bf1 (#8055), platformViewId was
added to SemanticsNode. This field is non-zero when the SemanticsNode
represents a platform view and is typically used by embedders as a means
of identifying locations where a platform view's 'native' accessibility
tree should be injected into the platform-specific accessibility tree
constructed by the embedder.

Due to the intended use of this field, the Flutter framework is meant to
enforce that this node has a child count of zero.
2019-10-24 19:42:32 -07:00
Chris Bracken
5a0582c673 Remove TODO on embedder a11y unit tests (flutter/engine#13346)
Removes a TODO implying that the embedder accessibility unittests were
disabled due to flakiness.

The tests were originally disabled in
https://github.com/flutter/engine/pull/9482.

The issue tracking re-enabling the tests was
https://github.com/flutter/flutter/issues/35218.

This issue was resolved, and the tests re-enabled, in
https://github.com/flutter/engine/pull/9585.
2019-10-24 19:42:16 -07:00
Chinmay Garde
d62c916817 Add FlutterEngineRunsAOTCompiledDartCode to the embedder API. (flutter/engine#13319)
For embedder code that is configured for both AOT and JIT mode Dart execution
based on the Flutter engine being linked to, this runtime check may be used to
appropriately configure the `FlutterProjectArgs`. In JIT mode execution, the
kernel snapshots must be present in the Flutter assets directory specified in
the `FlutterProjectArgs`. For AOT execution, the fields `vm_snapshot_data`,
`vm_snapshot_instructions`, `isolate_snapshot_data` and
`isolate_snapshot_instructions` (along with their size fields) must be specified
in `FlutterProjectArgs`.
2019-10-23 14:49:56 -07:00
Chinmay Garde
b7705127a6 Allow embedders to update preferrred locales. (flutter/engine#13238)
This was previously only possible by sending an undocumented payload over an engine managed channel.
2019-10-22 17:50:01 -07:00
Chinmay Garde
0a7f937d04 Specify a human readable reason for an error from the embedder API. (flutter/engine#13218)
Fixes https://github.com/flutter/flutter/issues/42480
2019-10-17 17:29:37 -07:00
Chinmay Garde
d102e4086e Re-land "Custom compositor layers must take into account the device pixel ratio."
This reverts commit 674e5f911f1d19a0611b603968a8307415f75b35 and applies iOS fixes.
2019-10-17 14:07:51 -07:00
Chinmay Garde
7634e4d38b Add trace events around custom compositor callbacks. (flutter/engine#13212) 2019-10-17 14:07:11 -07:00
Chinmay Garde
674e5f911f Revert "Custom compositor layers must take into account the device pixel ratio. (#13193)" (flutter/engine#13211)
This reverts commit c805fb227166d2097a7795569df1365cb9e736a8.
2019-10-17 12:59:27 -07:00
Chinmay Garde
c805fb2271 Custom compositor layers must take into account the device pixel ratio. (flutter/engine#13193)
The contents rendered into the backing stores are already correctly scaled.
The initial implementation assumed this also held true for the metrics obtained
via embedded view parameters.

Fixes b/142699417
2019-10-17 12:04:13 -07:00
Chinmay Garde
395f1cda67 Remove incomplete static thread safety annotations. (flutter/engine#13151)
Fixes https://github.com/flutter/flutter/issues/42704.
2019-10-16 17:28:31 -07:00
Chinmay Garde
9004744d6e Allow embedders to specify a render task runner description. (flutter/engine#13124)
Embedders may use this to specify a thread whose event loop is managed by them
instead of the engine. In addition, specifying the same task runner for both
the platform and render task runners allows embedders to effectively perform
GPU rendering operations on the platform thread.

To affect this change, the following non breaking changes to the API have been
made:

* The `FlutterCustomTaskRunners` struct now has a new field `render_task_runner`
  for the specification of a custom render task runner.
* The `FlutterTaskRunnerDescription` has a new field `identifier`. Embedders
  must supply a unique identifier for each task runner they specify. In
  addition, when describing multiple task runners that run their tasks on the
  same thread, their identifiers must match.
* The embedder may need to process tasks during `FlutterEngineRun` and
  `FlutterEngineShutdown`. However, the embedder doesn't have the Flutter engine
  handle before `FlutterEngineRun` and is supposed to relinquish handle right
  before `FlutterEngineShutdown`. Since the embedder needs the Flutter engine
  handle to service tasks on other threads while these calls are underway,
  there exist opportunities for deadlock. To work around this scenario, three
  new calls have been added that allow more deliberate management of the Flutter
  engine instance.
  * `FlutterEngineRun` can be replaced with `FlutterEngineInitialize` and
    `FlutterEngineRunInitialized`. The embedder can obtain a handle to the
    engine after the first call but the engine will not post any tasks to custom
    task runners specified by the embedder till the
    `FlutterEngineRunInitialized` call. Embedders can guard the Flutter engine
    handle behind a mutex for safe task runner interop.
  * `FlutterEngineShutdown` can be preceded by the `FlutterEngineDeinitialize`
    call. After this call the Flutter engine will no longer post tasks onto
    embedder managed task runners. It is still embedder responsibility to
    collect the Flutter engine handle via `FlutterEngineShutdown`.
* To maintain backwards compatibility with the old APIs, `FlutterEngineRun` is
  now just a convenience for `FlutterEngineInitialize` and
  `FlutterEngineRunInitilaized`. `FlutterEngineShutdown` now implicitly calls
  `FlutterEngineDeinitialize` as well. This allows existing users who don't care
  are custom task runner interop to keep using the old APIs.
* Adds complete test coverage for both old and new paths.

Fixes https://github.com/flutter/flutter/issues/42460
Prerequisite for https://github.com/flutter/flutter/issues/17579
2019-10-15 14:26:31 -07:00
sjindel-google
5ea9c249cd Remove use of the blobs snapshot format from unittests (flutter/engine#12563)
* Remove uses of the "blobs" snapshot format in Engine tests.

* Comments

* Rebasing against updated ELF loader API.
2019-10-10 14:03:42 +02:00
CloudWebRTC
2362c4e741 Add texture support for macOS shell. (flutter/engine#8507) 2019-10-09 20:35:09 -07:00
Chris Yang
cc04914ab4 Add onUnregistered callback in 'Texture' and 'FlutterTexture' (flutter/engine#12695)
Texture unregistration is finished on the GPU thread. The FlutterTexture implementation might not know when it is finished which leads to a race condition. Adding this callback so the FlutterTexture is aware of end of the unregistration process.
2019-10-08 12:45:57 -07:00
liyuqian
7bffe3c0a8 SkSL precompile (flutter/engine#12412)
For https://github.com/flutter/flutter/issues/40686

Unit tests added:
- CacheSkSLWorks
- VisitFilesCanBeCalledTwice
- CanListFilesRecursively
2019-10-08 11:51:28 -07:00
Chinmay Garde
b05e9e7d6a Add a unit-test to verify that root surface transformation affect platform view coordinates. (flutter/engine#12783)
See b/141980393 for details.

In the issue, the embedder (assumed to render Flutter contents of size 800 x 600 [1]) is meant to be displayed on its side. To achieve this, it specifies a root surface transformation that translates the surface by its width (or height when it held in the correct viewing position) and then rotates it counter-clockwise by 90 degrees. This test verifies that the Flutter Engine accounts for those transformations in the custom compositor platform view coodinates.

[1] The actual size is something different. 800x600 is for illustrative purposes.
2019-10-08 11:30:00 -07:00
Kate Lovett
73b60d4d7c Re-land Adding Link Semantics (flutter/engine#12972) 2019-10-08 11:27:56 -07:00
Kate Lovett
0106398abd Revert "Adding Link SemanticsFlag (#12453)" (flutter/engine#12815)
This reverts commit 62e4f42e7640ee5f50fef9958b50906a5527d81a.
2019-10-04 17:06:32 -07:00
Kate Lovett
62e4f42e76 Adding Link SemanticsFlag (flutter/engine#12453) 2019-10-04 12:51:10 -07:00
Chinmay Garde
7bcb751f24 Disable EmbedderTest::CanLaunchAndShutdownMultipleTimes. (flutter/engine#12799)
Re-enabling this is tracked in https://github.com/flutter/flutter/issues/41999
2019-10-04 11:45:00 -07:00
Greg Spencer
5302cb60b3 Add missing flag for embedder. (flutter/engine#12700)
Adding missing flag for IsFocusable that I missed in #12618
2019-09-30 11:21:01 -07:00
liyuqian
2778d3bb20 Revert "[fuchsia] Wire up OpacityLayer to Scenic (#11322)" (flutter/engine#12610)
This reverts commit 639cc113f0b2ccf9fcf69ded7960d41d0b611f80.

Fixes https://github.com/flutter/flutter/issues/41394 and other
related correctness issues.

TBR: @arbreng @jason-simmons @mehmetf
2019-09-27 16:50:43 -07:00
David Worsham
639cc113f0 [fuchsia] Wire up OpacityLayer to Scenic (flutter/engine#11322)
On Fuchsia, add a build flag for compositing OpacityLayers using the system
compositor vs Skia, which exposes a fastpath for opacity via Scenic.
This will only work under certain circumstances, in particular nested
OpacityLayers will not render correctly!

On Fuchsia, add a build flag for compositing PhysicalShapeLayers using
the system compositor vs Skia. Set to off by default, which restores
performant shadows on Fuchsia.

Remove the opacity exposed from ChildView, as that was added mistakenly.

Finally, we centralize the logic for switching between the
system-composited and in-process-composited paths inside of
ContainerLayer. We also centralize the logic for computing elevation
there. This allows the removal of many OS_FUCHSIA-specific code-paths.

Test: Ran workstation on Fuchsia; benchmarked before and after
Bug: 23711
Bug: 24163

* Fix broken tests
2019-09-25 12:48:42 -04:00
chunhtai
051ed653cc Add system font change listener for windows (flutter/engine#12276)
* Add windows font change logic

* update

* fix comment
2019-09-23 13:23:46 -07:00
Chinmay Garde
c8ecb03fa8 Account for root surface transformation on the surfaces managed by the external view embedder. (flutter/engine#11384)
The earlier design speculated that embedders could affect the same
transformations on the layers post engine compositor presentation but before
final composition.

However, the linked issue points out that this design is not suitable for use
with hardware overlay planes. When rendering to the same, to affect the
transformation before composition, embedders would have to render to an
off-screen render target and then apply the transformation before presentation.
This patch negates the need for that off-screen render pass.

To be clear, the previous architecture is still fully viable. Embedders still
have full control over layer transformations before composition. This is an
optimization for the hardware overlay planes use-case.

Fixes b/139758641
2019-09-17 15:16:59 -07:00
Chinmay Garde
7dda245874 Shuffle test order and repeat test runs once. (flutter/engine#12275)
The tests we write must be resilient to the order in which they are run in the
harness. That is, they must not rely on global state set by other tests that
have already run in the process. Also, these tests must themselves be
repeatable. That is, they must correctly clean up after themselves and be able
to run successfully again in the same process.

This patch adds some safeguards against (but does NOT guarantee) the addition of
tests that violate the dictum.

Additionally, test failures must be easily reproducible for folks investigating
the test failure. Also, tests that assert correctness of unrelated code must not
stop progress on the authors patch.

This changes does not hinder reproducibility of test failures because the random
seed is printed in the logs before running each test. Developers attempting to
reproduce the failure locally can do the same via the following invocation
`--gtest_shuffle --gtest_repeat=<the count> --gtest_random_seed=<seed from failing run>`.

This change does introduce potential burden on patch authors that may see
failures in unrelated code as a newly failing shuffle seed is used on their
runs. To ameliorate this, we will formulate guidance for them to aggressively
mark such tests as disabled and file bugs to enable the same.

The test seed is intentionally kept low because it’s purpose is to test that
individual tests are repeatable. It must not be used as a replacement for
fuzzing.
2019-09-17 14:50:51 -07:00
Chinmay Garde
5d6d4e450d Don't launch the observatory by default on each embedder unit-test invocation. (flutter/engine#12087)
There is no test to assert this and it unnecessarily slows down the test
harness and opens tons of port on the host.
2019-09-09 19:58:36 -07:00
Amir Hardon
d857db54ce Skip empty platform view overlays. (flutter/engine#11427)
This change sets up a "spying canvas" to try and detect empty canvases.
When using platform views with a custom embedder, if a platform view
overlay canvas is known to be empty we skip creating a compositor layer
for that overlay.
2019-08-26 11:40:49 -07:00
Chinmay Garde
7132a8a12d Avoid root surface acquisition during custom composition with software renderer. (flutter/engine#11394)
Uses the same technique used during OpenGL composition to elide root surface access. The refactoring of this approach is tracked in https://github.com/flutter/flutter/issues/38466

Fixes https://github.com/flutter/flutter/issues/39009.
2019-08-23 13:52:06 -07:00
Chinmay Garde
05d4ab774d Remove deprecated ThreadTest::GetThreadTaskRunner and use the newer CreateNewThread API. (flutter/engine#11395)
We will end up creating fewer threads in tests.
2019-08-23 12:21:46 -07:00
Chinmay Garde
88361b8cb4 Wire up software rendering in the test compositor. (flutter/engine#11392) 2019-08-22 20:27:34 -07:00
Chinmay Garde
7c368ef794 Dry up fixture comparison in embedder unit-tests. (flutter/engine#11359)
No functional change. Just makes testing with fixture images easier. Adding a
whole lot more tests that use this path for the embedder surface rotation
patches. Want to land stuff in smaller chunks.
2019-08-21 16:03:38 -07:00
stuartmorgan
59964aa29c Fix change_install_name.py to be GN-friendly (flutter/engine#11309)
change_install_name.py was operating on framework library files
in-place, which breaks GN's timestamp analysis handling since a file
can't be both an input and output of an action. As a result no-op builds
on macOS were not actually no-ops.

This changes the script to operate on an output copy, both fixing the
no-op build issue, and simplifying the GN framework construction scripts
by combining the copy step and the install-name step.

Fixes https://github.com/flutter/flutter/issues/33465
2019-08-20 21:15:42 -07:00
Chinmay Garde
288c3c01ef Migrate Embedder API documentation to Doxygen format. (flutter/engine#11255)
Fixes https://github.com/flutter/flutter/issues/38870
2019-08-20 20:20:06 -07:00
Chinmay Garde
68a6bf0c1f When using a custom compositor, ensure the root canvas is flushed. (flutter/engine#11310)
The root canvas is managed by the external view embedder when using a custom
compositor. Due to this, frame submission on the surface will not end up
flushing the same (because the surface doesn’t have it to begin with). Fixed
with tests.
2019-08-20 17:06:57 -07:00
Jason Simmons
b7345ada3c Fix a segfault in EmbedderTest.CanSpecifyCustomTaskRunner (flutter/engine#11305)
This test queues tasks to a custom task runner that runs the tasks on the
platform thread.  After shutting down the engine, the test must wait until
these tasks are drained before the test exits.
2019-08-20 14:11:45 -07:00
Chinmay Garde
4aa768d100 Provide a placeholder queue ID for the custom embedder task runner. (flutter/engine#11062)
This issue would only manifest when a custom task runner was being used with
a custom compositor. Both were tested separately but not together. A new
test has been added for this. We still create the GPU thread merger
unnecessarily but I can patch that later. I also cleaned up the existing
custom task runner test to not submit tasks on a dead engine as they just
log errors unnecessarily.

Filed new: https://github.com/flutter/flutter/issues/38844
2019-08-19 15:56:58 -07:00
Chinmay Garde
591f55b39d Allow embedder controlled composition of Flutter layers. (flutter/engine#10195)
This patch allows embedders to split the Flutter layer tree into multiple
chunks. These chunks are meant to be composed one on top of another. This gives
embedders a chance to interleave their own contents between these chunks.

The Flutter embedder API already provides hooks for the specification of
textures for the Flutter engine to compose within its own hierarchy (for camera
feeds, video, etc..). However, not all embedders can render the contents of such
sources into textures the Flutter engine can accept. Moreover, this composition
model may have overheads that are non-trivial for certain use cases. In such
cases, the embedder may choose to specify multiple render target for Flutter to
render into instead of just one.

The use of this API allows embedders to perform composition very similar to the
iOS embedder. This composition model is used on that platform for the embedding
of UIKit view such and web view and map views within the Flutter hierarchy.
However, do note that iOS also has threading configurations that are currently
not available to custom embedders.

The embedder API updates in this patch are ABI stable and existing embedders
will continue to work are normal. For embedders that want to enable this
composition mode, the API is designed to make it easy to opt into the same in an
incremental manner.

Rendering of contents into the “root” rendering surface remains unchanged.
However, now the application can push “platform views” via a scene builder.
These platform views need to handled by a FlutterCompositor specified in a new
field at the end of the FlutterProjectArgs struct.

When a new platform view in introduced within the layer tree, the compositor
will ask the embedder to create a new render target for that platform view.
Render targets can currently be OpenGL framebuffers, OpenGL textures or software
buffers. The type of the render target returned by the embedder must be
compatible with the root render surface. That is, if the root render surface is
an OpenGL framebuffer, the render target for each platform view must either be a
texture or a framebuffer in the same OpenGL context. New render target types as
well as root renderers for newer APIs like Metal & Vulkan can and will be added
in the future. The addition of these APIs will be done in an ABI & API stable
manner.

As Flutter renders frames, it gives the embedder a callback with information
about the position of the various platform views in the effective hierarchy.
The embedder is then meant to put the contents of the render targets that it
setup and had previously given to the engine onto the screen (of course
interleaving the contents of the platform views).

Unit-tests have been added that test not only the structure and properties of
layer hierarchy given to the compositor, but also the contents of the texels
rendered by a test compositor using both the OpenGL and software rendering
backends.

Fixes b/132812775
Fixes flutter/flutter#35410
2019-08-13 14:53:19 -07:00
Chinmay Garde
ae4cefbdcf When setting up AOT snapshots from symbol references, make buffer sizes optional. (flutter/engine#10674) 2019-08-08 20:31:23 -07:00
Chinmay Garde
d7dfe2cb03 Allow embedders to control Dart VM lifecycle on engine shutdown. (flutter/engine#10652)
This exposes the `Settings::leak_vm` flag to custom embedders. All embedder
unit-tests now shut down the VM on the shutdown of the last engine in the
process. The mechanics of VM shutdown are already tested in the Shell unit-tests
harness in the DartLifecycleUnittests set of of assertions. This just exposes
that functionality to custom embedders. Since it is part of the public stable
API, I also switched the name of the field to be something less snarky than the
field in private shell settings.
2019-08-06 16:15:37 -07:00
Dan Field
cd18c5ef0b Remove get engine (flutter/engine#9747) 2019-07-30 17:11:04 -07:00
stuartmorgan
1299da0e74 Add a macro for prefixing embedder.h symbols (flutter/engine#9851)
embedder.h is a C API, so has no namespace, and only uses 'Flutter' as a
prefix for most symbol names. This creates potential collisions with
other code; for instance, FlutterEngine is the name of a type in
embedder.h, but also an ObjC class in the iOS Flutter API.

This adds a macro that can be set to prefix symbol names, allowing
clients (notably, the macOS embedding) to adjust the names used by the
embedding API internally without breaking ABI or API compatibility for
the standard engine build.

Currently the macro is only applied to FlutterEngine, since that's the
symbol that is currently at issue, but it can be expanded to other
symbols in the future.
2019-07-23 05:48:48 -07:00
Jason Simmons
b48ddc3d9c Declare a copy of the enable_bitcode flag within the Flutter build scripts for use in Fuchsia builds (flutter/engine#10003)
enable_bitcode is defined in build/toolchain/clang.gni, which exists in the
Flutter buildroot but not in the Fuchsia source tree.
2019-07-22 12:06:16 -07:00
stuartmorgan
934901b4e8 Don't try to use unset assets_dir setting (flutter/engine#9924)
Debug builds log invalid file errors on launch of anything using the
embedding API due to an unconditional use of assets_dir, even though
only one of assets_dir or assets_path needs to be set (and the embedding
API currently uses the latter). This checks that the FD has been set
before trying to use it to create an asset resolver.

Also eliminates a duplicate code path in embedder.cc, where it was
calling RunConfiguration::InferFromSettings, then running exactly the
same asset manager creation code again locally.
2019-07-18 14:07:13 -07:00
Dan Field
f743db9bf5 Add clang version to Info.plist (flutter/engine#9873) 2019-07-17 12:14:07 -07:00