Commit b137b49a authored by liberato@chromium.org's avatar liberato@chromium.org Committed by Commit Bot

Skip ScopedMakeCurrent if context IsCurrent().

ui::ScopedMakeCurrent can crash during stub destruction, so we skip
it if the (shared) context is already current.

Bug: 839605
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel
Change-Id: Ifaa73ecc84bb335b1e154f38139a41b6ee37cdb9
Reviewed-on: https://chromium-review.googlesource.com/1055879Reviewed-by: default avatarDale Curtis <dalecurtis@chromium.org>
Commit-Queue: Frank Liberato <liberato@chromium.org>
Cr-Commit-Position: refs/heads/master@{#558033}
parent a49cb7d6
...@@ -66,11 +66,20 @@ SurfaceTextureGLOwner::~SurfaceTextureGLOwner() { ...@@ -66,11 +66,20 @@ SurfaceTextureGLOwner::~SurfaceTextureGLOwner() {
// Make sure that the SurfaceTexture isn't using the GL objects. // Make sure that the SurfaceTexture isn't using the GL objects.
surface_texture_ = nullptr; surface_texture_ = nullptr;
ui::ScopedMakeCurrent scoped_make_current(context_.get(), surface_.get()); std::unique_ptr<ui::ScopedMakeCurrent> scoped_make_current;
if (scoped_make_current.Succeeded()) {
glDeleteTextures(1, &texture_id_); // If the context is current, skip ScopedMakeCurrent to prevent (a) a
DCHECK_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); // potentially heavyweight virtual context switch and (b) a potential crash
// during stub destruction (https://crbug.com/839605).
if (!context_->IsCurrent(nullptr)) {
scoped_make_current =
std::make_unique<ui::ScopedMakeCurrent>(context_.get(), surface_.get());
if (!scoped_make_current->Succeeded())
return;
} }
glDeleteTextures(1, &texture_id_);
DCHECK_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
} }
GLuint SurfaceTextureGLOwner::GetTextureId() const { GLuint SurfaceTextureGLOwner::GetTextureId() const {
......
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