Index: mojo/services/native_viewport/native_viewport_android.cc |
diff --git a/mojo/services/native_viewport/native_viewport_android.cc b/mojo/services/native_viewport/native_viewport_android.cc |
index 55b88c9f514ed53390c639a6cef94a59b22e9d6c..9eb80835479297a466f67e0762dec36b0fee0357 100644 |
--- a/mojo/services/native_viewport/native_viewport_android.cc |
+++ b/mojo/services/native_viewport/native_viewport_android.cc |
@@ -60,7 +60,13 @@ void NativeViewportAndroid::SurfaceCreated(JNIEnv* env, |
jobject obj, |
jobject jsurface) { |
base::android::ScopedJavaLocalRef<jobject> protector(env, jsurface); |
- window_ = ANativeWindow_fromSurface(env, jsurface); |
+ // Note: This ensures that any local references used by |
+ // ANativeWindow_fromSurface are released immediately. This is needed as a |
+ // workaround for https://code.google.com/p/android/issues/detail?id=68174 |
+ { |
+ base::android::ScopedJavaLocalFrame scoped_local_reference_frame(env); |
+ window_ = ANativeWindow_fromSurface(env, jsurface); |
+ } |
delegate_->OnAcceleratedWidgetAvailable(window_); |
} |