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
This commit is contained in:
Jamie Nicol 2023-01-24 15:31:31 +00:00
Родитель 1308dc5edb
Коммит 5c4015fd4f
1 изменённых файлов: 2 добавлений и 2 удалений

Просмотреть файл

@ -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