From dcf0fe2c579d3d9bd64c688d2c02e86866dcd428 Mon Sep 17 00:00:00 2001 From: Bo Liu Date: Thu, 11 Jun 2015 14:11:49 -0700 Subject: Synchronously drop tile textures in android webview Merely applying zero memory is not enough to synchronously drop all tile textures. Instead destroy and recreate TileManager instead. BUG=496057, 499004 CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel Review URL: https://codereview.chromium.org/1176713002 Cr-Commit-Position: refs/heads/master@{#334020} (cherry picked from commit 3d442d362ddec4594dc12983d88bdbe24f1c361c) TBR=boliu@chromium.org Review URL: https://codereview.chromium.org/1178223005. Cr-Commit-Position: refs/branch-heads/2403@{#286} Cr-Branched-From: f54b8097a9c45ed4ad308133d49f05325d6c5070-refs/heads/master@{#330231} --- cc/trees/layer_tree_host_impl.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc index 5e02cab..ae6fcb8 100644 --- a/cc/trees/layer_tree_host_impl.cc +++ b/cc/trees/layer_tree_host_impl.cc @@ -1296,6 +1296,20 @@ void LayerTreeHostImpl::NotifyTileStateChanged(const Tile* tile) { void LayerTreeHostImpl::SetMemoryPolicy(const ManagedMemoryPolicy& policy) { SetManagedMemoryPolicy(policy); + + // This is short term solution to synchronously drop tile resources when + // using synchronous compositing to avoid memory usage regression. + // TODO(boliu): crbug.com/499004 to track removing this. + if (!policy.bytes_limit_when_visible && tile_manager_ && + settings_.using_synchronous_renderer_compositor) { + ReleaseTreeResources(); + // TileManager destruction will synchronoulsy wait for all tile workers to + // be cancelled or completed. This allows all resources to be freed + // synchronously. + DestroyTileManager(); + CreateAndSetTileManager(); + RecreateTreeResources(); + } } void LayerTreeHostImpl::SetTreeActivationCallback( -- cgit v1.1