TL;DR: Offscreen surface is created on the render thread and device to host
transfer performed there before task completion on the UI thread.
While attempting to snapshot layer trees, the engine was attempting to use the
IO thread context. The reasoning was that this would be safe to do because any
textures uploaded to the GPU as a result of async texture upload would have
originated from this context and hence the handles would be valid in either
context. As it turns out, while the handles are valid, Skia does not support
this use-case because cross-context images transfer ownership of the image from
one context to another. So, when we made the hop from the UI thread to the IO
thread (for snapshotting), if either the UI or GPU threads released the last
reference to the texture backed image, the image would be invalid. This led to
such images being absent from the layer tree snapshot.
Simply referencing the images as they are being used on the IO thread is not
sufficient because accessing images on one context after their ownership has
already been transferred to another is not safe behavior (from Skia's
perspective, the handles are still valid in the sharegroup).
To work around these issues, it was decided that an offscreen render target
would be created on the render thread. The color attachment of this render
target could then be transferred as a cross context image to the IO thread for
the device to host tranfer.
Again, this is currently not quite possible because the only way to create
cross context images is from encoded data. Till Skia exposes the functionality
to create cross-context images from textures in one context, we do a device to
host transfer on the GPU thread. The side effect of this is that this is now
part of the frame workload (image compression, which dominate the wall time,
is still done of the IO thread).
A minor side effect of this patch is that the GPU latch needs to be waited on
before the UI thread tasks can be completed before shell initialization.
* Revert "Revert "Roll buildtools to 759274dd801b2f78ae0c4066101d0beca27ffc9a" (#6621)"
This reverts commit 9de880cc909c6a687aabb9fbe98fd2e7476fd7e8.
* Revert "Properly gate android API < 21 and remove extraneous data array. (#6619)"
This reverts commit 8cb3965a3ebf1c65d03a78fc6c0b84a8adc3024f.
* Revert "Update Dart version in Dockerfile (#6618)"
This reverts commit 2091c0db69d7ba7772b05564f60c25612e0aaaf4.
* Revert "Don't attempt to build any platform target on Fuchsia. (#6617)"
This reverts commit 739d66eeb3f8777f3e28d3e635a5f691a0f1a16b.
* Revert "Roll Dart to 45f9462398ae7d2e80acd79d3f9c32c7ca6f6f97 (#6616)"
This reverts commit 7d49036d8b14f679509e64bff6f91644cbe11151.
* Revert "Pass null instead of 'none' locale (#6613)"
This reverts commit 6c84c5f6aea84797d9cdc787b342c6a5994524f1.
This reverts commit 74662ab695238af0e7402f41c4bf9ad862bd37d2.
This should land after https://github.com/flutter/engine/pull/6442
* Add pragma vm:entry-point
Otherwise, an object may be both null and an instance of EnginieLayer at
the same time in Dart.
* [dart] Roll dart to b99bcfd3099f0d32e39287160a9539e878cb0b68
Changes since last roll:
```
b99bcfd309 [vm] Add a library and class cache to KernelProgramInfo
5deb1c6e81 [vm] Remove strong mode and sync-async flags from pkg/vm
9a6f811466 Report null error as a NoSuchMethodError
2da0b9f4f1 fix some typos
34f6aea008 [release] Prepare changelog for 2.1.0-dev.7.0
f320477ff9 [dartdevc] add module-name option to kernel backend
b8760fed67 [vm, compiler] Remove ASTs and AST flow graph builder.
340e74629f Clean up OverrideVerifier.
f11e746c2e Initial implementation of fixes for type arguments on named constructor invocations
08e485c43f Update dartdoc to 0.23.1.
ac4b8a7306 Hook up FixProcessor to fix errors in dartfix
0aa99cca99 Ignore JSON exceptions when reading (empty) test results file
6d9cc6fa03 Add skeleton for parsing LSP spec from Markdown/TypeScript to generate Dart data classes
bc4d2f5d1b Switch InheritanceManager2Test to DriverResolutionTest.
e221a6288b Move reporting MISMATCHED_GETTER_AND_SETTER_TYPES for classes to using new interfaces.
be39eacf00 Rename convertPathForImport -> convertAbsolutePathToUri
a539d2ef5f Revert "[fasta] Report errors for bounds violations"
c8b709d95b Update status files after aa6fb2d3
051108c004 [tools] Re-enable core-dump archiving on Linux.
aa5b1b1f2f Make test results in json format end with a newline
4db2bbe94d Pass SharedOptions to Fasta
f1d902f4a0 Ignore --supermixin and -D options
a9b47bd0b1 Integrated nosuchmethod-forwarding.md into dartLangSpec.tex
327a1a9a00 [Gardening] Mark more co19_2 test as always flaky, filed co19 issues
f1b6d81404 Remove Target.strongMode
7072d3b17e [infra] Upgrade d8 to 6.9.427.23 (#34698)
16ddfc1565 [VM] Use assert assignable implementation for explicit downcasts
17ac151f44 [Gardening] Increase timeout on release-hotreload configuration as well (not just debug), skip streamed_conversion_json_utf8_decode in hot-reload-simdbc64
8c872e0e3a Remove TargetFlags.strongMode
ee97806084 Replace strongMode with legacyMode in CompilerOptions
aa6fb2d3a4 [fasta] Report errors for bounds violations
8247fb7eec Stop stripping d8 for benchmarking.
da48c1d960 [Gardening] Mark more tests as flaky and filed co19 issues
41866e87da [Gardening] Mark co19_2 test as always flaky, filed co19 issue (and co19 PR)
ecd13de9da [Gardening] Mark slow_path_shared_stub_test as slow (reaches 1 minute on windows)
f942af451b Remove kernel interpreter
7007567685 Fix issue with --unsafe-package-serialization
2695f36016 [Gardening] Status update (co19_2, optcounter/ia32)
ba5e14b195 Store return type and parameters separately in GenericFunctionTypeElementForLink.
ba1b30af37 Add AST support for type arguments on named constructors
ed6c557d1a Add cli parameters to kernel_sdk.dart to get all paths explicitly
71395df7dd [vm/interpreter] Fix flaky errors when running with interpreter
b3af151325 Rework detection of uninstantiated bound errors.
34651d204e [gardening] Update status
f35465dafd Remove DynamicElementImpl.library property.
daa13ad0aa Fix preamble/d8.js currentScript for v8 6.9
9cde31ba1d Try interface candidates in reverse order.
5561e69f4e Replace dartfix confirm apply changes with --force
619a06370e Update dartfix to only allow target directories
751cf1974a [dart/fuzzer] Add DBC as execution mode.
70317473f0 [gardening] Update status
8fc80031ae Fix cast exception in OpTypeAstVisitor
2cf6ba2996 Generate the right error message for type arguments on a named constructor
5976fe373f Fix up InferredTypeTest_Driver to use InferredTypeMixin directly.
32c484bb71 [VM] Fix typo in BitTestImmediate unit test.
a8e0db1077 [gardening] Mark remaining ASAN failures.
7f55e52888 [vm, x64] Use short forms for object pool loads.
a66cae48fc [vm/aot] Dynamic invocation forwarders in AOT.
4400df4190 Convert strong_mode_test.dart to triple-slash comment style.
c1361963aa Update status files for tests failing due to #34724 and #34724
0039aff1e3 [test] Remove use of --error_on_bad_type and --error_on_bad_override.
ce08911515 [vm/compiler] Minor improvements to loop detection
a2cf88bee6 [vm] Fix sync-async stack navigation to handle inlined functions.
920d75f2ea Cleanup dartfix driver context
746034785d Update dartfix to separate targets from analysis roots
3d06427075 Fix MOVE_FILE test paths for Windows
```
* Remove use of await_is_keyword flag.
* Update license
Provide a relative, per-image limit to the amount of memory
that's used to cache decoded image frames. Adds an overridable default
that developers can set to control how much memory images are allowed
to use decoded vs undecoded. The cap is set in flutter/flutter#22452.
Note that required frames are always cached regardless of the ratio cap,
because they're currently necessary for the GIF to animate. Previously
cached unessential frames are not cleared in response to the cache
hitting or exceeding the cap.
Addresses #20998 and #14344.
This reverts commit 5340f422481a69b4234b2a61f39c486f158b6eed, relands single root filesystem that is needed for reusable platform kernel files, that is safe to land now since dart roll c048bec5d23d0c1bfc0afb980d64940442aa93e1 has the fix for previously broken dependency file generation.
To make the PR minimal, we currently only share the engine layer when `pushPhysicalShape` (for Fuchsia) or `pushOffset` (for `RepaintBoundary` and `Opacity`) are called. They should be sufficient for our short-term perf goal. In the future, we can incrementally share more engine layers with the framework.
https://github.com/flutter/flutter/issues/21756
Skia should already have such optimizations based on a much more
accurate clip stack. As we move to the retained rendering, SceneBuilder
would be much harder to maintain such cull_rects_ stack so let's just
remove them.
No significant performance change is measured locally on Moto G4 with
flutter_gallery transition perf test and complex_layout scroll perf
test.
* Roll dart to c688d0c0c3ad3dece3a79ce0e115d787a94707ea.
Changes since last roll:
```
c688d0c0c3 [frontend] When serializing compiled expression proc, clone type params first.
346895eb35 Choose the right platform in the command-line fasta tool in strong mode
51d530475a [frontend] Honor embedSourceText option in incremental compiler.
06792cb91f Remove StackListener.popList
69cd7cb43f [infra] Add compare_results.dart and update_flakiness.dart.
c3c4e63ce4 Adjusted spec to use package syntax, thus eliminating bnf.sty
0315707dec Add 'set' case to type_variable_conflict_test
00f2054242 Add --repeat flag to test.py, so tests can be run multiple times
cf5cdea808 Add J/K versions CommonElements and ElementEnvironment
1681241062 Remove _ClassEnsurer
a5b71813ab Use json expectation files in dynamic tests
d560887ae5 Fix TypeError in Observatory
867c5271be Debugging dart in methods with dynamic type arguments
2e3f17fa2b Add support for the new mixin syntax to supertype constraint checking and resynthesis.
929b2fbc55 Adjust status file to account for CustomIsolates test passing now.
f0974aee20 Remove entry_points option from the test harness (should fix the precompiler bot failure).
296e4aa7e6 Split mixin_declaration_inference_valid_classes_test.dart into multiple tests.
2c427d33fc Train the dartanalyzer on less source.
41273507b2 Detect references to instance variables without declared type.
a0776096b9 Cleanup some of the build rules to not use Dart 1 mode.
3463f94ed9 Delete any existing version of a DevFS file before overwriting the file
7763ec3cd1 Surface analyzer toplevel inference limitations as DDC errors.
a386c07281 [vm/aot] Add extra call specialization pass
878017481f Roll dart_style to 1.2.0.
a890d95a26 [vm/compiler] Avoid !(x>y) -> x<=y on fp operands.
bc79674bc1 [vm/aot] Fix inferred type of implicitly initialized final fields
7df4900a94 Train the dartanalyzer tool on generating summaries.
80c1b88626 Add copyright comments in resolution tests.
bbe49524be Cache mapping from subtypes names to files where they are subtyped.
cf67e402bd Add test case reproducing issues #34498 and #34500.
81ce969060 Enable implicit constructors with optional parameters in mixin applications.
cb331064e0 Compare AnalysisOptions signatures in analyzer_cli.
eb059a76f3 Keep analyzer-specific status entries together in language_2_analyzer.status
62ce86e20c Add --test-list and --repeat options to test.py, for deflaking
9e86c1a395 Normalize strong.status
3831da8743 Include all problems in expectations
a1bd50168e Make input validation optional
6fe272314d Tweak parameters of ProcessedOptions
0a5d7b866d Update status files after de984e58.
de984e58cb Type checking for redirecting factories.
4134b95a3d [vm/tfa] Streamline handling of tear-offs in TFA
d44ffba254 [vm/tfa] Stop accepting non-empty entry points json files
30f0026022 [VM runtime] Fix type test: C is a subtype of C<FutureOr> (fixes#34482).
bbe83465ea Test that type of the ListLiteral with two different enums is inferred.
37b41bd317 Update status files after d4148159cc39d3f38d8295cf79ed736c6337d7ac
d9fcaa33b1 Implement StreamTransformer.fromBind
abb392fc0d add Pubspec.dependencyOverrides
c733ed7fd7 firefix status for LayoutTests/fast/dom/Range/getClientRects-character_t01
d4148159cc Initial valid inference checks
dcabf2cb0e Test for mixin declaration isObject and tweaks for error verifier.
```
* Update license
The `dart_vm_entry_points.txt` file is now deprecated in favor of annotations.
Support for parsing and generating the entry-points files will be removed from Dart shortly.
This essentially reverts https://github.com/flutter/engine/pull/4197/
as no one is (or soon will be) implementing an alternative LayerBuilder.
Let's just put everything in SceneBuilder to reduce the YAGNI
(you aren't gonna need it) smell. This will also make retained rendering
API changes much easier.