forked from firka/flutter
Bugfix: Prevent crash when responding to a platform message after FlutterJNI detaches from native (#28651). (flutter/engine#8170)
This commit is contained in:
@@ -10,6 +10,7 @@ import android.graphics.SurfaceTexture;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.UiThread;
|
||||
import android.util.Log;
|
||||
import android.view.Surface;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
@@ -494,8 +495,11 @@ public class FlutterJNI {
|
||||
|
||||
@UiThread
|
||||
public void invokePlatformMessageEmptyResponseCallback(int responseId) {
|
||||
ensureAttachedToNative();
|
||||
nativeInvokePlatformMessageEmptyResponseCallback(nativePlatformViewId, responseId);
|
||||
if (isAttached()) {
|
||||
nativeInvokePlatformMessageEmptyResponseCallback(nativePlatformViewId, responseId);
|
||||
} else {
|
||||
Log.w(TAG, "Tried to send a platform message response, but FlutterJNI was detached from native C++. Could not send. Response ID: " + responseId);
|
||||
}
|
||||
}
|
||||
|
||||
// Send an empty response to a platform message received from Dart.
|
||||
@@ -506,13 +510,16 @@ public class FlutterJNI {
|
||||
|
||||
@UiThread
|
||||
public void invokePlatformMessageResponseCallback(int responseId, ByteBuffer message, int position) {
|
||||
ensureAttachedToNative();
|
||||
nativeInvokePlatformMessageResponseCallback(
|
||||
nativePlatformViewId,
|
||||
responseId,
|
||||
message,
|
||||
position
|
||||
);
|
||||
if (isAttached()) {
|
||||
nativeInvokePlatformMessageResponseCallback(
|
||||
nativePlatformViewId,
|
||||
responseId,
|
||||
message,
|
||||
position
|
||||
);
|
||||
} else {
|
||||
Log.w(TAG, "Tried to send a platform message response, but FlutterJNI was detached from native C++. Could not send. Response ID: " + responseId);
|
||||
}
|
||||
}
|
||||
|
||||
// Send a data-carrying response to a platform message received from Dart.
|
||||
|
||||
Reference in New Issue
Block a user