Commit 8990e350 authored by Peng Huang's avatar Peng Huang Committed by Commit Bot

Fix low end device content_browsertests

The CL fixes two problems which cause the test failure.
1. Vulkan surface is destroyed asynchronousl. When chrome re-creates
   vulkan surface with the same AWindow, the old vulkan surface may
   still exist. And then the new vulkan surface creation will fail.
2. GrContext is abandoned when chrome goes into background, and then the
   same GrContext will be reused when chrome goes back to foreground
   again.

Bug: 1033170,1012282,1048692
Change-Id: Iedcb524d1215329c89c32fb633414e167e77bd15
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2036442
Commit-Queue: Peng Huang <penghuang@chromium.org>
Reviewed-by: default avatarVasiliy Telezhnikov <vasilyt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#738322}
parent cdf105b2
......@@ -6,6 +6,7 @@
#include <utility>
#include "base/system/sys_info.h"
#include "build/build_config.h"
#include "components/viz/common/gpu/vulkan_context_provider.h"
#include "gpu/command_buffer/service/memory_tracking.h"
......@@ -38,15 +39,29 @@ SkiaOutputDeviceVulkan::SkiaOutputDeviceVulkan(
SkiaOutputDeviceVulkan::~SkiaOutputDeviceVulkan() {
DCHECK(!scoped_write_);
for (auto it = sk_surface_size_pairs_.begin();
it != sk_surface_size_pairs_.end(); ++it) {
memory_type_tracker_->TrackMemFree(it->bytes_allocated);
}
sk_surface_size_pairs_.clear();
if (vulkan_surface_) {
#if defined(OS_ANDROID)
if (base::SysInfo::IsLowEndDevice()) {
// For low end device, output surface will be destroyed when chrome goes
// into background. And a new output surface will be created when chrome
// goes to foreground again. The vulkan surface cannot be created
// successfully, if the old vulkan surface is not destroyed. To avoid the
// problem, we sync the device queue, and destroy the vulkan surface
// synchronously.
vkQueueWaitIdle(context_provider_->GetDeviceQueue()->GetVulkanQueue());
vulkan_surface_->Destroy();
return;
}
#endif
auto* fence_helper = context_provider_->GetDeviceQueue()->GetFenceHelper();
fence_helper->EnqueueVulkanObjectCleanupForSubmittedWork(
std::move(vulkan_surface_));
}
for (auto it = sk_surface_size_pairs_.begin();
it != sk_surface_size_pairs_.end(); ++it) {
memory_type_tracker_->TrackMemFree(it->bytes_allocated);
}
}
bool SkiaOutputDeviceVulkan::Reshape(const gfx::Size& size,
......
......@@ -363,8 +363,15 @@ void SharedContextState::MarkContextLost() {
// context_state_ could be nullptr for some unittests.
if (context_state_)
context_state_->MarkContextLost();
if (gr_context_)
gr_context_->abandonContext();
// Only abandon the GrContext if it is owned by SharedContextState, because
// the passed in GrContext will be reused.
// TODO(https://crbug.com/1048692): always abandon GrContext to release all
// resources when chrome goes into background with low end device.
if (owned_gr_context_) {
owned_gr_context_->abandonContext();
owned_gr_context_.reset();
gr_context_ = nullptr;
}
UpdateSkiaOwnedMemorySize();
std::move(context_lost_callback_).Run();
for (auto& observer : context_lost_observers_)
......
......@@ -8,9 +8,6 @@
-MSE_*ClearKey/EncryptedMediaTest.*
-SRC_*ClearKey/EncryptedMediaTest.*
# SkiaOutputSurfaceImplOnGpu::MakeCurrent Fails. https://crbug.com/1012282
-*CompositorImplLowEndBrowserTest.CompositorImplDropsResourcesOnBackground*
# FeatureList Flakes. https://crbug.com/1012372
-NavigationBrowserTest.HistoryBackCancelPendingNavigationUserGesture/1
-SitePerProcessBrowserTest.*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment