Commit 5c4015fd authored by Jamie Nicol's avatar Jamie Nicol
Browse files

Bug 1811929 - Fix JNI crash caused by passing incorrect jobject type. r=gfx-reviewers,nical

The function ANativeWindow_fromSurface() takes a jobject that is
supposed to be a Surface. Prior to bug 1706656 GeckoSurface was a
subclass of Surface, meaning we passed the correct type. However,
GeckoSurface no longer derives from Surface meaning we hit this JNI
crash.

To fix this, call GeckoSurface->GetSurface() to get the underlying
Surface object.

Note that this code path is only active if the user has modified the
pref gfx.use-surfacetexture-textures. So although the volume is high,
it appears to be limited to a small number of users.

Differential Revision: https://phabricator.services.mozilla.com/D167659
parent 1308dc5e
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -111,8 +111,8 @@ AndroidNativeWindowTextureData::AndroidNativeWindowTextureData(
    java::GeckoSurface::Param aSurface, gfx::IntSize aSize,
    gfx::SurfaceFormat aFormat)
    : mSurface(aSurface), mIsLocked(false), mSize(aSize), mFormat(aFormat) {
  mNativeWindow =
      ANativeWindow_fromSurface(jni::GetEnvForThread(), mSurface.Get());
  mNativeWindow = ANativeWindow_fromSurface(jni::GetEnvForThread(),
                                            mSurface->GetSurface().Get());
  MOZ_ASSERT(mNativeWindow, "Failed to create NativeWindow.");

  // SurfaceTextures don't technically support BGR, but we can just pretend to