373 Commits

Author SHA1 Message Date
Sebastian Jeltsch
ac4e9832c9 Try rasterizing images and layers only once, even when their rasterization fails. Further enforce the same access threshold on layers as on Pictures. Previously layers would always be cached. The latter is a semantic change. (flutter/engine#16545)
If Rasterization fails, i.e. image.is_valid() is false, the cache might try rasterizing the image again on the next frame. Not only is this wasteful put might also prevent other pictures to be cached within the current frame budget.
2020-02-28 12:13:22 -08:00
Sebastian Jeltsch
e7e1637bd9 Fix RasterCache LRU logic, opportunistic simplifications. (flutter/engine#16434)
RasterCache::Get() methods were not updating the RasterCache::Entry
access_count and used_this_frame fields, as is done in
RasterCache::Prepare(). This can result in onscreen images being evicted
from the cache as new entries are created (e.g. as new elements scroll
onscreen).
2020-02-06 13:15:51 -08:00
Chinmay Garde
c243987f16 Fix race in SkiaGPUObject unit-tests. (flutter/engine#16351)
There are two issues in the test as written:
* There is a race on the first check to dtor_task_queue_id which might be
  encountered if the calling thread is de-scheduled and the unref queue manages
  to collect the object before the end of the scope.
* Two threads were owning a shared object but we relied on the object to be
  collected on the unref queue.
2020-02-03 19:57:43 -08:00
Chinmay Garde
426c48aaac Remove all uses of the redundant flutter_root variable. (flutter/engine#16311)
This was only necessary when the Engine had to build in multiple buildroots
where the sources where checked out at different paths relative to the
buildroot. This is no longer the case and there are already cases GN rules
have been written that mix and match variable usage with the direct
specification of the path to the Flutter sources relative to the sole buildroot.
2020-01-31 21:49:48 -08:00
Dan Field
62a99c60c5 the the fix (flutter/engine#15973) 2020-01-24 12:43:32 -08:00
David Worsham
ec3aedb2f2 Fix Opacity performance regression on Fuchsia (flutter/engine#15573)
* Add more profile markers

* Revert FuchsiaSystemCompistedLayer changes

* Re-add opacity w/o elevation changes

* Fix formatting
2020-01-16 15:28:48 -08:00
Jim Graham
77b9134e96 Engine support for ImageFiltered widget (flutter/engine#14491)
web_ui support coming in https://github.com/flutter/flutter/issues/47163
2019-12-19 16:47:08 -08:00
mikejurka
36839c42a7 Wire up OpacityLayer to Scenic (flutter/engine#14577)
A previous version of this change also removed
system compositing of PhysicalShapeLayers on
Fuchsia. In this reland, keep using system
composting for PhysicalShapeLayers.

Co-authored-by: David Worsham <arbreng@gmail.com>
2019-12-19 23:25:43 +01:00
Kaushik Iska
76d887b711 Reland Wire up Opacity on Fuchsia (flutter/engine#14559)
This reverts commit 6919709e47661c5cd48d9b0d3bfde986b9c1af84.

On top of the revert, it reverted a commit in the PR:
https://github.com/flutter/engine/pull/14024

This reverts commit ea67e5b0b930ebf552bc7dbd678a35ee6a129c39.
2019-12-18 16:05:38 -08:00
Kaushik Iska
6919709e47 Revert "Wire up Opacity on Fuchsia, round 2 (#14024)" (flutter/engine#14543)
This reverts commit cb0aca7f74a34a6a79f6b7123bd0643a135cf56a.
2019-12-18 10:29:47 -08:00
Jim Graham
17e3cf8e55 Conditionally use offscreen root surface only when needed
Currently helps primarily on iOS when no BackdropFilter is present by lowering energy usage
2019-12-11 15:10:55 -08:00
liyuqian
d067c4a259 Cleanup the IO thread GrContext (flutter/engine#14265)
Fixes https://github.com/flutter/flutter/issues/19558

This is tested by the devicelab test fast_scroll_large_images__memory
2019-12-10 16:02:02 -08:00
Jason Simmons
9a8367da7e Do not paint a layer's children if the children were not prerolled (flutter/engine#14149)
Prerolling a layer can have side effects.  In particular, PlatformViewLayer::Preroll
will call view_embedder->PrerollCompositeEmbeddedView.

Clip layers will check whether the layer's children are all clipped and if so
will skip calling Preroll on the children.  However, the Paint implementation in
these layers was always calling Paint on their children.

This could result in a call to PlatformViewLayer::Paint without a corresponding
call to PlatformViewLayer::Preroll.  This translates to a CompositeEmbeddedView
call without a PrerollCompositeEmbeddedView call on the affected view_id.
The EmbedderExternalViewEmbedder implementation does not allow that.

With this change, clip layers will only call PaintChildren if the preroll
called PrerollChildren.

See https://github.com/flutter/flutter/issues/46111
2019-12-05 16:25:55 -08:00
David Worsham
cb0aca7f74 Wire up Opacity on Fuchsia, round 2 (flutter/engine#14024)
* Remove erroneous ChildView opacity

* Wire frame metrics through contexts

* Maintain layer stack inside of SceneBuilder

* Remove EnsureSingleChild

* Centralize system-composite and elevation logic

* Wire up OpacityLayer to Scenic
2019-12-04 19:29:31 -08:00
David Worsham
df08c2593a Relanding: Add Flow unittests and fixtures (flutter/engine#14091) 2019-12-03 14:33:02 -08:00
liyuqian
52e74298e0 Revert PRs to unblock David and Jim's work (flutter/engine#14088)
* Revert "Add flow test fixtures and tests (#13986)"

This reverts commit 32915132bacdfd0d631421b23bb6a6d5db1095ab.

* Revert "Dynamically determine whether to use offscreen surface based on need (#13976)"

This reverts commit a13401ce86b3019c39154d56644b7b9eb4a5bbe5.
2019-12-03 12:02:37 -08:00
David Worsham
32915132ba Add flow test fixtures and tests (flutter/engine#13986) 2019-12-03 09:43:02 -08:00
Jim Graham
a13401ce86 Dynamically determine whether to use offscreen surface based on need (flutter/engine#13976)
Only use an offscreen surface on iOS if a layer which reads back from the destination surface, such as BackdropFilter, is present.
2019-11-27 15:01:25 -08:00
Chinmay Garde
dee0c26a36 Don't crash but warn when the scene builder specifies no layers. (flutter/engine#14008) 2019-11-25 15:38:41 -08:00
Kaushik Iska
e04a911e5c [fuchsia] Capture SkRRect in scene_update_context by value (flutter/engine#13989)
This was leading to usage of the captured rect after the end
of the lifetime in descrutor of Frame.
2019-11-22 16:29:58 -08:00
gaaclarke
ec5cf813f6 Made a way to turn off the OpenGL operations on the IO thread for backgrounded apps (flutter/engine#13908) 2019-11-22 14:08:33 -08:00
gaaclarke
43dce83fc1 Refactor to passing functions by const ref (flutter/engine#13975)
Moved our code to passing functions by const ref
2019-11-22 12:20:02 -08:00
Kaushik Iska
f6d868ede0 [fuchsia] Ensure we do not initialize nan RoundedRectangles (flutter/engine#13971)
Also initializes physical shape layer vars to empty.
2019-11-21 19:40:06 -08:00
liyuqian
b9f2bacea8 Fix picture raster cache throttling (flutter/engine#13710)
Previously, we're also counting the pictures that are already raster
cached.

This fixes https://github.com/flutter/flutter/issues/44252 and helps
solving the GPU thread issue of https://github.com/flutter/flutter/issues/43083

https://github.com/flutter/flutter/pull/45050 is a performance test in the framework repo to reveal this bug.
2019-11-20 16:36:23 -08:00
Chinmay Garde
6df221f6fb Expose the platform view mutator stack to custom compositors. (flutter/engine#13731)
This allows custom compositors to affect scene builder modifications made
to the platform view.

Fixes https://github.com/flutter/flutter/issues/44211
Fixes b/143612326
2019-11-19 10:35:41 -08:00
James Robinson
e9fb9f7bb8 [flow][fuchsia] Add more tracing to layers and Fuchsia surface pool (flutter/engine#13864)
This adds more trace events to more layer operations and enhances the
trace counters for the Fuchsia vulkan surface pool to include retained
surface counts, emit stats on recycle events that might change the
surface count, and by separating counters which measure bytes from
counters which measure counts to make analysis simpler.
2019-11-14 15:31:37 -08:00
Michael Klimushyn
24ba26f80c Turn on RasterCache based on view hierarchy (flutter/engine#13762)
This is a duplicate of flutter/engine#13360 with the test switched to use the software backend instead of the GL backend.

After some debugging and testing on another GL embedder I think the issue with the test is some bug having to do with the GL implementation in the test harness specifically. 

Fixes flutter/flutter#38903
2019-11-08 17:14:50 -08:00
Dan Field
5ac5df1fdd Fix mDNS for iOS13 (flutter/engine#13451) 2019-11-01 15:29:15 -07:00
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
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
7f34c88350 Do not attempt to drain the SkiaUnrefQueue in the destructor (flutter/engine#13237)
SkiaUnrefQueue should be empty at destruction time.  If the queue is nonempty,
then there will be a pending drain task that will hold a reference to the
queue.  The queue can only be destructed after the drain completes and the
reference is dropped.

Drains must only be done on the queue's task runner thread, which may not be
the thread where the queue is destructed.
2019-10-21 14:14:18 -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
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
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
Chinmay Garde
3873eeabb6 Compile sanitizer suppressions list and file bugs as necessary. (flutter/engine#12991) 2019-10-08 11:33:26 -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
Jonah Williams
c341326d6a Add support for JIT release mode (flutter/engine#12446) 2019-09-27 11:20:54 -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
Amir Hardon
f105e44be5 Update ExternalViewEmbedder class comment. (flutter/engine#11063) 2019-09-18 11:18:38 -06: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
liyuqian
f8f285edcc Support non-60 refresh rate on PerformanceOverlay (flutter/engine#11419)
So we can get the correct graph on 90fps/120fps devices :)

See https://github.com/flutter/flutter/issues/37888
2019-08-24 15:22:52 -07:00
Kaushik Iska
281ac5bf5a Do not Prepare raster cache if view_embedder is present (flutter/engine#11300)
This is a perf win because we do not use the cache in Paint anyways.
RasterCache <-> PlatformViews interaction will be improved by:
https://github.com/flutter/flutter/issues/38903
2019-08-20 14:38:45 -07:00
liyuqian
e099414b49 Trace RasterCacheResult::Draw (flutter/engine#11004)
Fixes https://github.com/flutter/flutter/issues/37988
2019-08-14 16:13:49 -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
Kaushik Iska
de1c728dab Allow for dynamic thread merging on IOS for embedded view mutations (flutter/engine#9819)
After pre-roll we know if there have been any mutations made to the IOS embedded UIViews. If there are any mutations and the thread configuration is such chat the mutations will be committed on an illegal thread (GPU thread), we merge the threads and keep them merged until the lease expires. The lease is currently set to expire after 10 frames of no mutations. If there are any mutations in the interim we extend the lease.

TaskRunnerMerger will ultimately be responsible for enforcing the correct thread configurations.

This configuration will be inactive even after this change since still use the same thread when we create the iOS engine. That is slated to change in the coming PRs.
2019-08-12 12:32:38 -07:00
cfontas
764e43e0e0 change add part to add child (flutter/engine#10787) 2019-08-09 12:18:44 -07:00
Kaushik Iska
f3f1b7c0b7 Revert "Remove one last final call to AddPart()" (flutter/engine#10440) 2019-08-02 09:18:17 -07:00
cfontas
d871e4da7f Remove one last final call to AddPart() (flutter/engine#10273)
* Remove one last final call to AddPart()

* fix merge conflict

* fix how i merged

* remove add part again

* remove pointer syntax

* fix formatting
2019-07-31 20:05:00 -07:00