Skip to content

Remove Android WebView from view system before calling destroy() #1161

@nfischer

Description

@nfischer

Bug description:

React-native needs to remove WebView from the view hierarchy before calling .destroy(). From this comment it seems react-native is not doing so:

...
W/cr_AwContents: WebView.destroy() called while WebView is still attached to window.
...

This probably isn't causing a crash (WebView tries to handle this case gracefully), but older versions of WebView may not handle this as gracefully (I've observed crashes on really old Android versions).

To Reproduce:

Not sure. This log message probably repros every time you trigger the cleanup code path.

Expected behavior:

The documentation states:

This method should be called after this WebView has been removed from the view system. No other methods may be called on this WebView after destroy.

https://developer.android.com/reference/android/webkit/WebView.html#destroy()

Screenshots/Videos:

N/A

Environment:

  • OS: Android
  • OS version: probably all
  • react-native version:
  • react-native-webview version:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions