Commit 804346fd authored by Eric Karl's avatar Eric Karl Committed by Commit Bot

Avoid creating SurfaceWrapper with null SurfaceView

SurfaceWrapper cannot be parceled / sent over IPC if it has a null
SurfaceView. See [1].

Before change [2] we wouldn't return a SurfaceWrapper with a null
SurfaceView from GpuProcessCallback.getViewSurface, but now we can,
leading to a crash during parceling.

This change updates the implementation so we won't generate a
SurfaceWrapper with a null SurfaceView.

[1] https://cs.chromium.org/chromium/src/content/public/android/java/src/org/chromium/content/common/SurfaceWrapper.java?rcl=478440c3d858369abbda6f79b92c7d4ca7d435bb&l=47
[2] https://chromium-review.googlesource.com/c/chromium/src/+/1597251/5/content/public/android/java/src/org/chromium/content/browser/GpuProcessCallback.java#b25

Bug: 991894
Change-Id: I8a88209643eba355a51840b43c5cfd9a8813bde7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1755346
Auto-Submit: Eric Karl <ericrk@chromium.org>
Commit-Queue: Yaron Friedman <yfriedman@chromium.org>
Reviewed-by: default avatarYaron Friedman <yfriedman@chromium.org>
Reviewed-by: default avatarKhushal <khushalsagar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#687641}
parent a5abb9e9
...@@ -41,6 +41,8 @@ JNI_GpuProcessCallback_GetViewSurface( ...@@ -41,6 +41,8 @@ JNI_GpuProcessCallback_GetViewSurface(
gl::ScopedJavaSurface surface_view = gl::ScopedJavaSurface surface_view =
gpu::GpuSurfaceTracker::GetInstance()->AcquireJavaSurface( gpu::GpuSurfaceTracker::GetInstance()->AcquireJavaSurface(
surface_id, &can_be_used_with_surface_control); surface_id, &can_be_used_with_surface_control);
if (surface_view.IsEmpty())
return nullptr;
return JNI_SurfaceWrapper_create(env, surface_view.j_surface(), return JNI_SurfaceWrapper_create(env, surface_view.j_surface(),
can_be_used_with_surface_control); can_be_used_with_surface_control);
} }
......
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