Skip to content

WebView crashes on second text selection [Android] #21239

@amirh

Description

@amirh

It looks like the selection handles are not removed from the window, and are being re-added on a second text selection which crashes the app with:

W/System.err(30171): java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.                                                            
W/System.err(30171):    at android.view.ViewGroup.addViewInner(ViewGroup.java:4309)                                                                                                                                
W/System.err(30171):    at android.view.ViewGroup.addView(ViewGroup.java:4145)                                                                                                                                     
W/System.err(30171):    at android.view.ViewGroup.addView(ViewGroup.java:4103)                                                                                                                                     
W/System.err(30171):    at android.widget.PopupWindow.createDecorView(PopupWindow.java:1233)                                                                                                                       
W/System.err(30171):    at android.widget.PopupWindow.preparePopup(PopupWindow.java:1177)                                                                                                                          
W/System.err(30171):    at android.widget.PopupWindow.showAtLocation(PopupWindow.java:1022)                                                                                                                        
W/System.err(30171):    at android.widget.PopupWindow.showAtLocation(PopupWindow.java:995)                                                                                                                         
W/System.err(30171):    at org.chromium.android_webview.PopupTouchHandleDrawable.show(PopupTouchHandleDrawable.java:237)                                                                                           
W/System.err(30171):    at org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)                                                                                                               
W/System.err(30171):    at org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:9)                                                                                                       
W/System.err(30171):    at android.os.Handler.dispatchMessage(Handler.java:102)                                                                                                                                    
W/System.err(30171):    at android.os.Looper.loop(Looper.java:148)                                                                                                                                                 
W/System.err(30171):    at android.app.ActivityThread.main(ActivityThread.java:5417)                                                                                                                               
W/System.err(30171):    at java.lang.reflect.Method.invoke(Native Method)                                                                                                                                          
W/System.err(30171):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)                                                                                                         
W/System.err(30171):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)               

Temporarily we prevent text selection in WebView to avoid the crash.

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: platform-viewsEmbedding Android/iOS views in Flutter appsp: webviewThe WebView pluginpackageflutter/packages repository. See also p: labels.platform-androidAndroid applications specifically

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions