Do not clear FlutterJNI state when a FlutterView is detached (flutter/engine#7929)
If an app is using retainFlutterNativeView or a plugin wants to keep the FlutterNativeView active, then the FlutterNativeView should not drop its handle to the corresponding native platform view. Fixes https://github.com/flutter/flutter/issues/26931
This commit is contained in:
@@ -109,8 +109,6 @@ public class FlutterEngine {
|
||||
pluginRegistry.detach();
|
||||
dartExecutor.onDetachedFromJNI();
|
||||
flutterJNI.removeEngineLifecycleListener(engineLifecycleListener);
|
||||
// TODO(mattcarroll): investigate detach vs destroy. document user-cases. update code if needed.
|
||||
flutterJNI.detachFromNativeButKeepNativeResources();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -392,15 +392,6 @@ public class FlutterJNI {
|
||||
|
||||
private native long nativeAttach(FlutterJNI flutterJNI, boolean isBackgroundView);
|
||||
|
||||
@UiThread
|
||||
public void detachFromNativeButKeepNativeResources() {
|
||||
ensureAttachedToNative();
|
||||
nativeDetach(nativePlatformViewId);
|
||||
nativePlatformViewId = null;
|
||||
}
|
||||
|
||||
private native void nativeDetach(long nativePlatformViewId);
|
||||
|
||||
@UiThread
|
||||
public void detachFromNativeAndReleaseResources() {
|
||||
ensureAttachedToNative();
|
||||
|
||||
@@ -50,7 +50,6 @@ public class FlutterNativeView implements BinaryMessenger {
|
||||
mPluginRegistry.detach();
|
||||
dartExecutor.onDetachedFromJNI();
|
||||
mFlutterView = null;
|
||||
mFlutterJNI.detachFromNativeButKeepNativeResources();
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
|
||||
@@ -160,11 +160,6 @@ static jlong AttachJNI(JNIEnv* env,
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(mattcarroll): delete this method here and in FlutterJNI.java
|
||||
static void DetachJNI(JNIEnv* env, jobject jcaller, jlong shell_holder) {
|
||||
// Nothing to do.
|
||||
}
|
||||
|
||||
static void DestroyJNI(JNIEnv* env, jobject jcaller, jlong shell_holder) {
|
||||
delete ANDROID_SHELL_HOLDER;
|
||||
}
|
||||
@@ -547,11 +542,6 @@ bool RegisterApi(JNIEnv* env) {
|
||||
.signature = "(Lio/flutter/embedding/engine/FlutterJNI;Z)J",
|
||||
.fnPtr = reinterpret_cast<void*>(&shell::AttachJNI),
|
||||
},
|
||||
{
|
||||
.name = "nativeDetach",
|
||||
.signature = "(J)V",
|
||||
.fnPtr = reinterpret_cast<void*>(&shell::DetachJNI),
|
||||
},
|
||||
{
|
||||
.name = "nativeDestroy",
|
||||
.signature = "(J)V",
|
||||
|
||||
Reference in New Issue
Block a user