Fix crash when removeViewImmediate invoked from platform view (flutter/engine#6266)
* Fix crash when removeViewImmediate invoked from platform view * Clear animation before remove view from mFakeWindowRootView
This commit is contained in:
committed by
Michael Klimushyn
parent
1743aff91e
commit
cfd00c3d88
@@ -232,7 +232,8 @@ class SingleViewPresentation extends Presentation {
|
||||
* (see: https://github.com/flutter/flutter/issues/20714). This was triggered when selecting text in an embedded
|
||||
* WebView (as the selection handles are implemented as popup windows).
|
||||
*
|
||||
* This dynamic proxy overrides the addView, removeView, and updateViewLayout methods to prevent these crashes.
|
||||
* This dynamic proxy overrides the addView, removeView, removeViewImmediate, and updateViewLayout methods
|
||||
* to prevent these crashes.
|
||||
*
|
||||
* This will be more efficient as a static proxy that's not using reflection, but as the engine is currently
|
||||
* not being built against the latest Android SDK we cannot override all relevant method.
|
||||
@@ -266,6 +267,9 @@ class SingleViewPresentation extends Presentation {
|
||||
case "removeView":
|
||||
removeView(args);
|
||||
return null;
|
||||
case "removeViewImmediate":
|
||||
removeViewImmediate(args);
|
||||
return null;
|
||||
case "updateViewLayout":
|
||||
updateViewLayout(args);
|
||||
return null;
|
||||
@@ -296,6 +300,16 @@ class SingleViewPresentation extends Presentation {
|
||||
mFakeWindowRootView.removeView(view);
|
||||
}
|
||||
|
||||
private void removeViewImmediate(Object[] args) {
|
||||
if (mFakeWindowRootView == null) {
|
||||
Log.w(TAG, "Embedded view called removeViewImmediate while detached from presentation");
|
||||
return;
|
||||
}
|
||||
View view = (View) args[0];
|
||||
view.clearAnimation();
|
||||
mFakeWindowRootView.removeView(view);
|
||||
}
|
||||
|
||||
private void updateViewLayout(Object[] args) {
|
||||
if (mFakeWindowRootView == null) {
|
||||
Log.w(TAG, "Embedded view called updateViewLayout while detached from presentation");
|
||||
|
||||
Reference in New Issue
Block a user