未验证 提交 b32d0ab9 编写于 作者: M Matt Carroll 提交者: GitHub

Bugfix: Prevent crash when responding to a platform message after FlutterJNI...

Bugfix: Prevent crash when responding to a platform message after FlutterJNI detaches from native (#28651). (#8170)
上级 d9b2f094
......@@ -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.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册