Lock in Surface#destroy

Previously, destroy just directly called release, which was already
locked. Now, destroy invokes some functions in native. This means if
another thread is calling release during the destroy call, it could
cause crashes.

Test: Hard to repro bug
Bug: 223412469
Change-Id: Ie6415f505bbc86505e3fe3ea2a0bea96a3e78ad3
This commit is contained in:
chaviw
2022-05-10 12:40:58 -05:00
parent c0ba829902
commit 40e361cb78

View File

@@ -341,10 +341,12 @@ public class Surface implements Parcelable {
*/
@UnsupportedAppUsage
public void destroy() {
if (mNativeObject != 0) {
nativeDestroy(mNativeObject);
synchronized (mLock) {
if (mNativeObject != 0) {
nativeDestroy(mNativeObject);
}
release();
}
release();
}
/**