-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(android): Prevent libhwui crash when WebView is in ScrollView #2874
Conversation
This looks really promising! I was not able to get it to crash yet after removing all previous crash prevention workarounds we had on the simulator in our production app. Without the workarounds, it would instantly crash on load. But I notice something odd. It appears the webview is not triggering the |
good catch! will follow up soon. |
Also |
|
Excellent, Things are running great now. I don't have a real device to reproduce this easily on, but I will send an update to Google Play, set the crashes as resolved in Sentry, and check if they resurface. Thanks so much for looking into this! (PS: I DM'd you on Twitter) |
cool! thanks much for your testing and even willing to try it on production directly. hopes the solution doing well and fixes the problem for you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the investigation/PR!
I don't quite follow the last bit of the description about how using a FrameLayout
"creates a dedicated Android canvas"? i.e., how does the FrameLayout
avoid the clipping problem?
Also, this overlaps/conflicts with some other PRs, such as the new architecture support (#2686) and "keeping native WebView in memory when react component is unmounted" (#2469). The latter of which is not close to being merged, but it does a similar thing with refactoring to wrap the WebView
in a FrameLayout
...
android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java
Outdated
Show resolved
Hide resolved
Huge thanks to @Kudo for investigating and finally fixing these crashes. The image shows the Android crash rate before the fix. It should hopefully finally go to 0. Been a tough couple of years for our Android users. I haven't seen a single crash in Sentry related to webviews since deploying this fix. |
that's just my hypothesis and could be wrong. i tried to dig out more for the difference. unfortunately, to really figure out the whole thing, we may need a custom AOSP with native debug symbols and set breakpoints in native side. as far as my understanding, a View (also ViewGroup) will have an underlying RenderNode and RecordingCanvas. having a new canvas might not cause the crash. i guess the difference might come from here. without FrameLayout, it MAY go to the if block and the with FrameLayout, it MAY go to the else block and there's i would say that's somehow an android's bug where not handle the case when GLFunctorDrawable clipBounds is empty. if wrapping webview in FrameLayout doesn't impact to react-native-webview much, we could try to have this and avoid the crash from android.
totally understand there's much more work for those conflict. i just want to find a way to fix the strange crash. let me know if there's anything i can do for this pr. thanks! |
Here's a list of crashes from the Google Play console prior to applying this patch: We've been running the patched version for a few days now, and none of those crashes still exist. There's only this one though, occured a single time. Not sure if something in this PR might be the cause: More details here: https://letspoker.sentry.io/share/issue/bc60aa7fef5a49498c9cdac79aa89b48/ |
this updated commit should address this crash: 4674ae8 looks like it is caused when webview messages happen even after the webview is being removed. |
Amazing work, waiting for it to enter the main branch as it's an issue that's been plaguing us as well |
Adding this to the pile of things I need to take care of! Thanks @Kudo |
@Titozzz perhaps you could consider adding some new maintainers? Maybe from the Expo team, if they're up for it? 🫶 |
haha we're just a small team at expo and may not have much bandwidth and expertise to maintain many libraries. @Titozzz and all the react-native-webview maintainers are great and actively maintain this library. i don't think it's necessary to look up for new maintainers. as a good react native community, we should collaborate together anyway 🙌 |
As a user of this library, I have great respect for @Titozzz and the other maintainers. However, in my experience, it seems that the library is not currently being actively maintained. I fully understand that open source is difficult and that the maintainers are working on this in their free time. However, I have noticed that a critical issue has gone unacknowledged for over two years, and I am concerned about this. I assume that if they were using the library in their own projects they'd have noticed this issue themselves. I would like to suggest that perhaps the maintainers could consider adding more contributors to the project, rather than handing over the keys entirely. I know from personal experience that maintaining libraries can be a time-consuming task, and additional help could be very beneficial. Please do not take this the wrong way - I am only offering a friendly suggestion. 🫶 @jamonholmgren seems to agree that more maintainers are needed as per this https://twitter.com/jamonholmgren/status/1628995972314591232 |
@andreialecu which critical issue has gone unacknowledged? I am curious to hear more about this |
That's just one of them, this is also the same issue: #575 (see stack trace) and is from 2019 |
Just to clarify, I am not going to spend many hours fixing any issue that isn't affecting everyone. I will gladly merge and discuss any solution but this community package has always work like that for 5 years succesfully which I feel is a huge community achievement! As Kudo said this is a package were we all collaborate. As for adding new maintainers I'm happy to have more people on board, but I'm not going to add everyone that just wants to get his PR in and then disappear, it wouldn't make sense. Do you think since I don't actively read issues I should close the tabs and just keep the PR + discussions ? |
#623 All of these are the exact same issue. These are also this issue, but from other repos: react-navigation/react-navigation#9067 There's a plethora of other assorted reports everywhere, including StackOverflow and other places. https://stackoverflow.com/questions/56553663/react-native-null-pointer-dereference-after-navigating-to-from-a-page-containi @Kudo was a godsend for getting to the bottom of it.
Not reading issues is why I feel this library is not being maintained. There's no alternative in the RN ecosystem to react-native-webview and it seems like a critical piece of the puzzle. You guys could probably get some of the big corporate users of react-native who have been active lately in this space to sponsor some maintenance work. Just trying to provide positive feedback. |
if those issues are all the same, i would say it's a SUPER HARD problem though. not only have to get a repro but also need some background of chromium, android webview adapter and the android framework. though i was a browser engineer, till now i'm not figuring out the exact root case. i think everyone want to get this problem fixed, it's just tough. other than this tough issue, i think the react-native-webview quality/maintenance should be healthy. |
One other thing to note is that I have had this happen in absolutely every app I work on with react native, to the point where I actively avoid having to use react-native-webview and try to use other things like https://www.npmjs.com/package/react-native-render-html or more lately something like https://github.com/cawfree/react-native-wormhole So I genuinely wonder how it didn't get any attention in the past 4 years. Our apps are not even doing anything particularly special. This crash is very easy to run into.
I agree it's a super hard problem, and those are definitely all related to this issue. If you look inside the details they're all webview related. I've been dealing with it for years, and I know all the workarounds. Even with all of them in place, you can still see that the crash rate was 8% or so (down from 100% on some devices). |
As a fellow maintainer (and user of I have been reading and responding to issues and reviewing PRs. There's currently a long backlog of PRs only because of the new architecture work, which is a massive refactor of the entire library. My team did spend a lot of time investigating this a few years ago, but we finally settled on the |
* i cant believe i wasted a lot of my time for this.. thank you Mr. Kudo Chien for throughly investigating this manner. * while disabling gl_checkpoints may reduce frequent sys ui crash to a near stable please avoid using skiagl until google itself fixes the issue reference: react-native-webview/react-native-webview#2874 Signed-off-by: minaripenguin <minaripenguin@users.noreply.github.com>
* i cant believe i wasted so much time for this.. thank you Mr. Kudo Chien for throughly investigating this manner. * while disabling gl_checkpoints may reduce frequent sys ui crash to a near stable please avoid using skiagl until google itself fixes the issue reference: react-native-webview/react-native-webview#2874 Signed-off-by: minaripenguin <minaripenguin@users.noreply.github.com>
please merge |
Any updates on this? Is there an issue in the RN repo about this? |
Could anyone confirm when this might be merged? |
Can we please get an update on this? |
For confirmation, for the last 5 months, we have been running this PR as a patch on an app that has roughly 500 000 active Android installations, and the web view related crashing practically stopped when we applied the patch. |
3e10664
to
d0747f9
Compare
resolved
did some smoke testing on the sorry be late to response, hopes we can get the pr merged this time. |
This fix worked for me. Thanks @Kudo! |
After internal discussion, I've decided to move this forward as this is the only fix and the "quickest" (it tooks already too long) way to get it to everyone. Thanks @Kudo and everyone involved |
## [13.6.2](v13.6.1...v13.6.2) (2023-10-06) ### Bug Fixes * **android:** Prevent libhwui crash when WebView is in ScrollView ([#2874](#2874)) ([886664d](886664d))
🎉 This PR is included in version 13.6.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
OMG thank you all!! |
yesssss, thank you all and @Kudo 🙏🏽 🙏🏽 🙏🏽 |
thanks @Titozzz for having this pr forward 👏 🚀 |
That's fantastic news thank you very much to everyone involved. |
Great news! Thank you all |
Thank you very much |
* chore(ci): Update React Native to fix Android build (react-native-webview#2734) See facebook/react-native#35210 * chore(docs): Add information that custom menu items are only available for iOS (react-native-webview#2748) * feat(ios): Cookie sync improvements (react-native-webview#2535) * chore(release): 11.24.0 [skip ci] # [11.24.0](react-native-webview/react-native-webview@v11.23.1...v11.24.0) (2022-11-23) ### Features * **ios:** Cookie sync improvements ([react-native-webview#2535](react-native-webview#2535)) ([4ac0d74](react-native-webview@4ac0d74)) * feat(Android): Handle RESOURCE_PROTECTED_MEDIA_ID permission (react-native-webview#2732) * chore(release): 11.25.0 [skip ci] # [11.25.0](react-native-webview/react-native-webview@v11.24.0...v11.25.0) (2022-11-26) ### Features * **Android:** Handle RESOURCE_PROTECTED_MEDIA_ID permission ([react-native-webview#2732](react-native-webview#2732)) ([2711f3a](react-native-webview@2711f3a)) * fix(android): Respect "filename*" parameter in the field Content-Disposition when detecting filenames for downloading. (react-native-webview#2767) * chore(release): 11.25.1 [skip ci] ## [11.25.1](react-native-webview/react-native-webview@v11.25.0...v11.25.1) (2022-12-07) ### Bug Fixes * **android:** Respect "filename*" parameter in the field Content-Disposition when detecting filenames for downloading. ([react-native-webview#2767](react-native-webview#2767)) ([47c05b0](react-native-webview@47c05b0)) * feat(macos): Support File Input On Macos (react-native-webview#2733) * chore(release): 11.26.0 [skip ci] # [11.26.0](react-native-webview/react-native-webview@v11.25.1...v11.26.0) (2022-12-09) ### Features * **macos:** Support File Input On Macos ([react-native-webview#2733](react-native-webview#2733)) ([9b7ce57](react-native-webview@9b7ce57)) * chore: Update Getting-Started.md (react-native-webview#2791) * fix(js): messagingEnabled prop (react-native-webview#2666) This was always being set to "true", even if no onMessage handler was provided * chore(docs): Add info/warning about injectedJavaScriptBeforeContentLoaded for Android (react-native-webview#2746) * Add acknowledgement that injectedJavaScriptBeforeContentLoaded is implemented for Android, but warning that it may be unreliable * Linkify? * chore: bump react-native-macos to 0.68 (react-native-webview#2828) * chore(release): 11.26.1 [skip ci] ## [11.26.1](react-native-webview/react-native-webview@v11.26.0...v11.26.1) (2023-01-27) ### Bug Fixes * **js:** messagingEnabled prop ([react-native-webview#2666](react-native-webview#2666)) ([f74ee7a](react-native-webview@f74ee7a)) * chore(docs): Fix clearCache link in index (react-native-webview#2814) * chore(docs): README fixes: badge, minor wording tweaks (react-native-webview#2880) * chore: Update Guide.md (react-native-webview#2906) * feat: Fabric support (react-native-webview#2686) Hello everyone, the support for new architecture (fabric) is finally landing 🚀 . I've taken a lot of time but I've had to re-understand the whole codebase, the old arch, the new arch, and I did not want to take too many shortcuts. This release should be mostly non breaking (except for a few well deserved props removals). HOWEVER, this is a lot of code over a lot of time. Mistakes can happen, if you feel unsafe stick to v11 for a lil' while. Finally this will unblock many PR (sorry for the conflicts in advance), so let's get releasing again 🔥 If you appreciate my work please to [sponsor me](https://github.com/sponsors/Titozzz) BREAKING CHANGE: - If you are using custom native implementation are still possible on the old arch but many classes were moved / renamed so they will need some changes - removed the following props: androidHardwareAccelerationDisabled (deprecated), urlPrefixesForDefaultIntent (unused) * chore(release): 12.0.0 [skip ci] # [12.0.0](react-native-webview/react-native-webview@v11.26.1...v12.0.0) (2023-04-01) ### Features * Fabric support ([react-native-webview#2686](react-native-webview#2686)) ([5558e28](react-native-webview@5558e28)) ### BREAKING CHANGES * - If you are using custom native implementation are still possible on the old arch but many classes were moved / renamed so they will need some changes - removed the following props: androidHardwareAccelerationDisabled (deprecated), urlPrefixesForDefaultIntent (unused) * fix(iOS): Foundation Import (react-native-webview#2917) Fixed a build issue that could be happening on iOS see react-native-webview#2915 * chore(release): 12.0.1 [skip ci] ## [12.0.1](react-native-webview/react-native-webview@v12.0.0...v12.0.1) (2023-04-04) ### Bug Fixes * **iOS:** Foundation Import ([react-native-webview#2917](react-native-webview#2917)) ([a2eec17](react-native-webview@a2eec17)), closes [react-native-webview#2915](react-native-webview#2915) * fix(ios): fix userAgent ios type comment (react-native-webview#2888) * chore(release): 12.0.2 [skip ci] ## [12.0.2](react-native-webview/react-native-webview@v12.0.1...v12.0.2) (2023-04-06) ### Bug Fixes * **ios:** fix userAgent ios type comment ([react-native-webview#2888](react-native-webview#2888)) ([4d0c0de](react-native-webview@4d0c0de)) * fix(Android): Don't crash while downloading file with % in filename (react-native-webview#2861) * chore(release): 12.0.3 [skip ci] ## [12.0.3](react-native-webview/react-native-webview@v12.0.2...v12.0.3) (2023-05-22) ### Bug Fixes * **Android:** Don't crash while downloading file with % in filename ([react-native-webview#2861](react-native-webview#2861)) ([81e3aa4](react-native-webview@81e3aa4)) * bump min version (react-native-webview#2955) * chore: fix typo (react-native-webview#2868) * feat: make pushState changes trackable on android (react-native-webview#2929) Authored-by: Peter Lazar <peter.lazar@limehome.de> * chore(release): 12.1.0 [skip ci] # [12.1.0](react-native-webview/react-native-webview@v12.0.3...v12.1.0) (2023-05-23) ### Features * make pushState changes trackable on android ([react-native-webview#2929](react-native-webview#2929)) ([39ce007](react-native-webview@39ce007)) * Missing android.support.FILE_PROVIDER_PATHS meta-data on some OEMs (react-native-webview#2952) We (Microsoft Office apps) are seeing the following crashes in certain OEMs (biased toward Samsung) Exception java.lang.RuntimeException: Unable to get provider com.reactnativecommunity.webview.RNCWebViewFileProvider: java.lang.IllegalArgumentException: Missing android.support.FILE_PROVIDER_PATHS meta-data at android.app.ActivityThread.installProvider (ActivityThread.java:6840) at android.app.ActivityThread.installContentProviders (ActivityThread.java:6382) at android.app.ActivityThread.handleBindApplication (ActivityThread.java:6286) ... Caused by java.lang.IllegalArgumentException: Missing android.support.FILE_PROVIDER_PATHS meta-data at androidx.core.content.FileProvider.d at androidx.core.content.FileProvider.h at androidx.core.content.FileProvider.e at androidx.core.content.FileProvider.attachInfoMAM .. Upon further investigation, we found the hypothesis that some OEMs strip meta-data from the manifest (though we don't have any solid data to confirm). This discussion is related : https://issuetracker.google.com/issues/237727754?pli=1 And this commit into AOSP : https://android-review.googlesource.com/c/platform/frameworks/support/+/1978527 * feat(windows): Support headers and cookies in source prop (react-native-webview#2897) * [windows] Support headers and cookies in source prop * minor fixes * chore(release): 12.2.0 [skip ci] # [12.2.0](react-native-webview/react-native-webview@v12.1.0...v12.2.0) (2023-06-01) ### Features * **windows:** Support headers and cookies in source prop ([react-native-webview#2897](react-native-webview#2897)) ([1851ead](react-native-webview@1851ead)) * fix: Revert "Missing android.support.FILE_PROVIDER_PATHS meta-data on some OEMs (react-native-webview#2952)" This reverts commit 75e7801. * chore(release): 12.2.1 [skip ci] ## [12.2.1](react-native-webview/react-native-webview@v12.2.0...v12.2.1) (2023-06-10) ### Bug Fixes * Revert "Missing android.support.FILE_PROVIDER_PATHS meta-data on some OEMs ([react-native-webview#2952](react-native-webview#2952))" ([e17a79b](react-native-webview@e17a79b)) * feat: custom action menu on android + improved iOS (react-native-webview#2993) * Update RNCWebView.java * Update RNCWebView.java * wip * wip * fix build on latest xcode * add example + fix a few things * Update RNCWebViewImpl.m * fix macOS build * chore(release): 12.3.0 [skip ci] # [12.3.0](react-native-webview/react-native-webview@v12.2.1...v12.3.0) (2023-06-10) ### Features * custom action menu on android + improved iOS ([react-native-webview#2993](react-native-webview#2993)) ([f2aef66](react-native-webview@f2aef66)) * feat: debugging enabled prop (react-native-webview#2937) * feat: add webviewDebuggingEnabled prop & Android implementation fix: use static RNCWebView.setWebContentsDebuggingEnabled * feat: add iOS webviewDebuggingEnabled prop * chore: remove "link generted with jump2header" comments * chore: add missing props-index links in Reference.md * feat: add webviewDebuggingEnabled reference docs * fix: surround inspectable code blocks with compiler preprocessor to include only on appropriate versions --------- Co-authored-by: Tom Bury <tom.bury@twipemobile.com> * chore(release): 12.4.0 [skip ci] # [12.4.0](react-native-webview/react-native-webview@v12.3.0...v12.4.0) (2023-06-10) ### Features * debugging enabled prop ([react-native-webview#2937](react-native-webview#2937)) ([f9a5277](react-native-webview@f9a5277)) * feat: Allow webview to load in background tab (react-native-webview#2930) BREAKING CHANGE: This affects an existing loading behavior so we marked it as breaking, just in case Co-authored-by: Peter Lazar <peter.lazar@limehome.de> Co-authored-by: Thibault Malbranche <thibault@brigad.co> * chore(release): 13.0.0 [skip ci] # [13.0.0](react-native-webview/react-native-webview@v12.4.0...v13.0.0) (2023-06-10) ### Features * Allow webview to load in background tab ([react-native-webview#2930](react-native-webview#2930)) ([40c9807](react-native-webview@40c9807)) ### BREAKING CHANGES * This affects an existing loading behavior so we marked it as breaking, just in case Co-authored-by: Peter Lazar <peter.lazar@limehome.de> Co-authored-by: Thibault Malbranche <thibault@brigad.co> * feat(iOS): fraudulent website warning setting (previously react-native-webview#2801) (react-native-webview#2994) * feat: fraudulentWebsiteWarningEnabled * chore: test new arch on CI # Conflicts: # docs/Reference.md * fix: missing type * feat: add ios13 check * Update src/WebViewTypes.ts Co-authored-by: Caleb Clarke <TheAlmightyBob@users.noreply.github.com> * Update docs/Reference.md Co-authored-by: Caleb Clarke <TheAlmightyBob@users.noreply.github.com> * implem adaptation * Update ios-ci.yml * Update ios-ci.yml * Update android-ci.yml * Update ios-ci.yml * fix android new arch * Update ios-ci.yml --------- Co-authored-by: sunnylqm <sunnylqm@gmail.com> Co-authored-by: Caleb Clarke <TheAlmightyBob@users.noreply.github.com> * chore(release): 13.1.0 [skip ci] # [13.1.0](react-native-webview/react-native-webview@v13.0.0...v13.1.0) (2023-06-10) ### Features * **iOS:** fraudulent website warning setting (previously [react-native-webview#2801](react-native-webview#2801)) ([react-native-webview#2994](react-native-webview#2994)) ([6d185e6](react-native-webview@6d185e6)) * feat(android): Add support for the `capture` attribute (react-native-webview#2954) Co-authored-by: Thibault Malbranche <thibault@brigad.co> * chore(release): 13.2.0 [skip ci] # [13.2.0](react-native-webview/react-native-webview@v13.1.0...v13.2.0) (2023-06-11) ### Features * **android:** Add support for the `capture` attribute ([react-native-webview#2954](react-native-webview#2954)) ([966221e](react-native-webview@966221e)) * fix: build on 0.72 new arch (react-native-webview#2997) * chore(release): 13.2.1 [skip ci] ## [13.2.1](react-native-webview/react-native-webview@v13.2.0...v13.2.1) (2023-06-12) ### Bug Fixes * build on 0.72 new arch ([react-native-webview#2997](react-native-webview#2997)) ([7ceeb2f](react-native-webview@7ceeb2f)) * fix(macOS): address regression due to didMoveToSuperview (react-native-webview#3006) Co-authored-by: Vahagn Nikoghosyan <vahagnn@meta.com> * chore(release): 13.2.2 [skip ci] ## [13.2.2](react-native-webview/react-native-webview@v13.2.1...v13.2.2) (2023-06-14) ### Bug Fixes * **macOS:** address regression due to didMoveToSuperview ([react-native-webview#3006](react-native-webview#3006)) ([41576ca](react-native-webview@41576ca)) * chore(docs): Add Italian translation to the docs 🇮🇹📖 (react-native-webview#3031) * fix: Revert didMoveToSuperview back to didMoveToWindow (react-native-webview#3041) Fixes multiple issues with the iOS new architecture (WebViews not rendering, javascript on pages not working, possibly more) and occasional crash with the iOS old architecture. * chore(release): 13.2.3 [skip ci] ## [13.2.3](react-native-webview/react-native-webview@v13.2.2...v13.2.3) (2023-07-18) ### Bug Fixes * Revert didMoveToSuperview back to didMoveToWindow ([react-native-webview#3041](react-native-webview#3041)) ([836f717](react-native-webview@836f717)) * chore: Update Guide.md to link a working static server package (react-native-webview#3049) The static server package does not seem to work in the later version of React Native. Or, there's a way to make it work but not discussed. A fork of this [library](https://github.com/birdofpreyru/react-native-static-server) works as expected. While it may not have many 'stars' the fact that it works and is also maintained, makes it a more suitable candidate. * feat: Add `onOpenWindow` event (react-native-webview#2640) * chore(release): 13.3.0 [skip ci] # [13.3.0](react-native-webview/react-native-webview@v13.2.3...v13.3.0) (2023-07-24) ### Features * Add `onOpenWindow` event ([react-native-webview#2640](react-native-webview#2640)) ([933fe19](react-native-webview@933fe19)) * chore(docs): Fix typo in Reference.md (react-native-webview#3071) * fix(docs): Reference documentation updates for menuItems (react-native-webview#3046) * chore(release): 13.3.1 [skip ci] ## [13.3.1](react-native-webview/react-native-webview@v13.3.0...v13.3.1) (2023-07-31) ### Bug Fixes * **docs:** Reference documentation updates for menuItems ([react-native-webview#3046](react-native-webview#3046)) ([fcd6050](react-native-webview@fcd6050)) * chore(docs): Update debugging instructions (react-native-webview#3029) * chore: bump react-native-macos to 0.71 (react-native-webview#3103) * chore: bump react-native-macos to 0.71 * keep `add:macos` * feat(iOS): Suppress menu items (react-native-webview#3082) * chore(release): 13.4.0 [skip ci] # [13.4.0](react-native-webview/react-native-webview@v13.3.1...v13.4.0) (2023-08-25) ### Features * **iOS:** Suppress menu items ([react-native-webview#3082](react-native-webview#3082)) ([5cd324c](react-native-webview@5cd324c)) * feat: Add clearCache method on iOS (react-native-webview#3119) * Add clearCache method on iOS * Update ClearData.tsx to remove comments Co-authored-by: Jamon Holmgren <jamonholmgren@gmail.com> * Update ClearData.tsx to remove commented code Co-authored-by: Jamon Holmgren <jamonholmgren@gmail.com> --------- Co-authored-by: Jamon Holmgren <jamonholmgren@gmail.com> * chore(release): 13.5.0 [skip ci] # [13.5.0](react-native-webview/react-native-webview@v13.4.0...v13.5.0) (2023-08-29) ### Features * Add clearCache method on iOS ([react-native-webview#3119](react-native-webview#3119)) ([0868f91](react-native-webview@0868f91)) * fix(ios): Fixes new ios clearCache method where it wasn't getting attached (react-native-webview#3122 by @jamonholmgren and @robinheinze) * chore(release): 13.5.1 [skip ci] ## [13.5.1](react-native-webview/react-native-webview@v13.5.0...v13.5.1) (2023-08-29) ### Bug Fixes * **ios:** Fixes new ios clearCache method where it wasn't getting attached ([react-native-webview#3122](react-native-webview#3122) by [@jamonholmgren](https://github.com/jamonholmgren) and [@robinheinze](https://github.com/robinheinze)) ([f101eaf](react-native-webview@f101eaf)) * feat(android): Android injectJavaScriptObject (react-native-webview#2960) * chore(release): 13.6.0 [skip ci] # [13.6.0](react-native-webview/react-native-webview@v13.5.1...v13.6.0) (2023-09-08) ### Features * **android:** Android injectJavaScriptObject ([react-native-webview#2960](react-native-webview#2960)) ([447f68e](react-native-webview@447f68e)) * chore(docs): Add InjectedJavaScriptObject link in Reference.md (react-native-webview#3139) * fix: add namespace to build.gradle for gradle 8 compat (required for 0.73) (react-native-webview#3055) * Update build.gradle * improve fix * Update build.gradle * Update build.gradle --------- Co-authored-by: Thibault Malbranche <malbranche.thibault@gmail.com> * chore(release): 13.6.1 [skip ci] ## [13.6.1](react-native-webview/react-native-webview@v13.6.0...v13.6.1) (2023-10-06) ### Bug Fixes * add namespace to build.gradle for gradle 8 compat (required for 0.73) ([react-native-webview#3055](react-native-webview#3055)) ([c4c8e4c](react-native-webview@c4c8e4c)) * fix(android): Prevent libhwui crash when WebView is in ScrollView (react-native-webview#2874) * fix(android): Prevent libhwui crash when WebView is in ScrollView * fix incorrect reactTag for event passing * fix regression from Background example test case * fix getParent NPE * Apply suggestions from code review * Fix rebase conflict * chore(release): 13.6.2 [skip ci] ## [13.6.2](react-native-webview/react-native-webview@v13.6.1...v13.6.2) (2023-10-06) ### Bug Fixes * **android:** Prevent libhwui crash when WebView is in ScrollView ([react-native-webview#2874](react-native-webview#2874)) ([886664d](react-native-webview@886664d)) * fix: Adds field `"react-native"` to `package.json` (react-native-webview#3209) * chore(release): 13.6.3 [skip ci] ## [13.6.3](react-native-webview/react-native-webview@v13.6.2...v13.6.3) (2023-11-22) ### Bug Fixes * Adds field `"react-native"` to `package.json` ([react-native-webview#3209](react-native-webview#3209)) ([ecc1100](react-native-webview@ecc1100)) * fix(iOS): update podspec to use install_modules_dependencies (react-native-webview#3231) * update podspec to be compatible with RN 0.72 * improved fallback * chore(readme): fix typos (react-native-webview#3270) Fixed grammar issues * fix(android): add buildFeatures.buildConfig true for AGP8+ compat (react-native-webview#3219) * chore(release): 13.6.4 [skip ci] ## [13.6.4](react-native-webview/react-native-webview@v13.6.3...v13.6.4) (2024-01-02) ### Bug Fixes * **android:** add buildFeatures.buildConfig true for AGP8+ compat ([react-native-webview#3219](react-native-webview#3219)) ([f849077](react-native-webview@f849077)) * **iOS:** update podspec to use install_modules_dependencies ([react-native-webview#3231](react-native-webview#3231)) ([b4f047a](react-native-webview@b4f047a)) * chore(docs): update cacheEnabled description (react-native-webview#3260) * chore(android): Update new architecture config (react-native-webview#3047) * Update podspec * Remove `react` block from `build.gradle` --------- Co-authored-by: Thibault Malbranche <thibault@brigad.co> * feat(Windows): Add support for custom headers, POST requests and `onOpenWindow` to Windows * Add WindowsWebViewCommands and implement releaseFocus * Fixes to setup request methos, added helpers class to visual studio project and fixed missing FocusManager namespace * Add LinkHandlingEnabled property to allow application to handle request by the webview to open new windows * Refactor cookie handling in ReactWebView2.cpp * Fix WebView source handling and add new commands * Add linkHandlingEnabled property to nativeProps * Add postMessage and loadUrl commands to command list * Add loadUrl function to WebViewComponent * Refactor string manipulation functions in ReactWebViewHelpers * Refactor cookie handling in ReactWebView2.cpp * Update RNCWebViewUIManagerWindows type in WebViewTypes.ts * Fix WebView messaging functionality * Add useWebView2 prop to WebView component * Update test to include alert support in WebView2 * Create Windows specific example components for testing webview scenarios * Update documentation --------- Co-authored-by: Kennedy Mumo <kemumo@microsoft.com> * chore(release): 13.7.0 [skip ci] # [13.7.0](react-native-webview/react-native-webview@v13.6.4...v13.7.0) (2024-01-31) ### Features * **Windows:** Add support for custom headers, POST requests and `onOpenWindow` to Windows ([9e2794e](react-native-webview@9e2794e)) * fix(Windows): Refactor ReactWebView2.cpp to handle optional 'method' parameter (react-native-webview#3319) Co-authored-by: Kennedy Mumo <kemumo@microsoft.com> * chore(release): 13.7.1 [skip ci] ## [13.7.1](react-native-webview/react-native-webview@v13.7.0...v13.7.1) (2024-02-06) ### Bug Fixes * **Windows:** Refactor ReactWebView2.cpp to handle optional 'method' parameter ([react-native-webview#3319](react-native-webview#3319)) ([f0791d8](react-native-webview@f0791d8)) * fix(ios, macos): Suspend media playback when destroying WebView on iOS/macOS (react-native-webview#3234) * Suspend media playback when destroying WebView on iOS/macOS * Fixes crash on iOS <15.0 and macOS <12.0 when pausing playback on dismount --------- Co-authored-by: Thibault Malbranche <thibault@brigad.co> * fix(iOS): Replace UIKit with RCTUIKit on MacOS for RCT_NEW_ARCH_ENABLED (react-native-webview#3296) * Replace UIKit with RCTUIKit on MacOS for RCT_NEW_ARCH_ENABLED * Exclude iOS specific destroy handler. * Fix `Non-constant-expression cannot be narrowed from type 'BOOL' (aka 'signed char') to 'bool' in initializer` when building for Release * Minor fix (typo) * chore(release): 13.7.2 [skip ci] ## [13.7.2](react-native-webview/react-native-webview@v13.7.1...v13.7.2) (2024-02-13) ### Bug Fixes * **iOS:** Replace UIKit with RCTUIKit on MacOS for RCT_NEW_ARCH_ENABLED ([react-native-webview#3296](react-native-webview#3296)) ([cb9fb9c](react-native-webview@cb9fb9c)) * **ios, macos:** Suspend media playback when destroying WebView on iOS/macOS ([react-native-webview#3234](react-native-webview#3234)) ([7af398c](react-native-webview@7af398c)) * feat(ios): ios injectJavaScriptObject (react-native-webview#3157) * feat(ios): injectedJavaScriptObject props connect * feat(ios): injectedJavaScriptObject ios component props * feat(ios): injectedObjectJsonScript addUserScript * refactor(ios): type position lines * revert: src/WebViewTypes.ts * docs: support injectedJavaScriptObject ios * remove log * fix(ios): return string single quote * chore(release): 13.8.0 [skip ci] # [13.8.0](react-native-webview/react-native-webview@v13.7.2...v13.8.0) (2024-02-13) ### Features * **ios:** ios injectJavaScriptObject ([react-native-webview#3157](react-native-webview#3157)) ([8013944](react-native-webview@8013944)) * Fix NuGet package reference (react-native-webview#3242) Co-authored-by: Thibault Malbranche <thibault@brigad.co> * chore(types): Indentation error (react-native-webview#3292) * fix(android): Fix WebViewManager can no longer be customized (react-native-webview#3315) * chore(release): 13.8.1 [skip ci] ## [13.8.1](react-native-webview/react-native-webview@v13.8.0...v13.8.1) (2024-02-13) ### Bug Fixes * **android:** Fix WebViewManager can no longer be customized ([react-native-webview#3315](react-native-webview#3315)) ([0068588](react-native-webview@0068588)) * Merge remote-tracking branch 'upstream/master' * fix: replace the RNCWebView to RNCWebViewImpl --------- Co-authored-by: Caleb Clarke <TheAlmightyBob@users.noreply.github.com> Co-authored-by: Handschrift <privacy.mtehw@aleeas.com> Co-authored-by: Matias Korhonen <matias.korhonen@kaikuhealth.com> Co-authored-by: semantic-release-bot <semantic-release-bot@martynus.net> Co-authored-by: enzo-macri <99820921+enzo-macri@users.noreply.github.com> Co-authored-by: Xun Sun <UNIDY2002@outlook.com> Co-authored-by: Amir Angel <36531255+17Amir17@users.noreply.github.com> Co-authored-by: Gregory <95241798+Gregory-Coelho@users.noreply.github.com> Co-authored-by: Tommy Nguyen <4123478+tido64@users.noreply.github.com> Co-authored-by: Richard <9120292+Reisclef@users.noreply.github.com> Co-authored-by: Jamon Holmgren <jamonholmgren@gmail.com> Co-authored-by: Pierre-Alain Bouly <pab50000@gmail.com> Co-authored-by: Thibault Malbranche <thibault@brigad.co> Co-authored-by: Piotr Kochanowski <63232710+TheKohan@users.noreply.github.com> Co-authored-by: Valentina M <valentinam@porch.com> Co-authored-by: Tatiana Kapos <tatianakapos@microsoft.com> Co-authored-by: flow <hyperflow@kakao.com> Co-authored-by: Peter Lazar <peterlazar1993@gmail.com> Co-authored-by: Anandraj <anandrag@microsoft.com> Co-authored-by: vahagnni <asvahagnas@gmail.com> Co-authored-by: Thibault Malbranche <malbranche.thibault@gmail.com> Co-authored-by: Tom Bury <tom.bury@hotmail.com> Co-authored-by: Tom Bury <tom.bury@twipemobile.com> Co-authored-by: Peter Lazar <peter.lazar@limehome.de> Co-authored-by: sunnylqm <sunnylqm@gmail.com> Co-authored-by: Rob X <robxyy@gmail.com> Co-authored-by: Vahagn Nikoghosyan <vahagnn@meta.com> Co-authored-by: Davide Palazzo <davide@revengecreative.com> Co-authored-by: Nikhil <6836536+qwertynik@users.noreply.github.com> Co-authored-by: Yannick Chiron <yannick.chiron@gmail.com> Co-authored-by: Pavlos Vinieratos <pvinis@gmail.com> Co-authored-by: Naveen <naveen.naveen@gmail.com> Co-authored-by: Tuur Dutoit <me@tuurdutoit.be> Co-authored-by: Arjan Zuidema <flecks@gmail.com> Co-authored-by: Robin Heinze <robin.m.heinze@gmail.com> Co-authored-by: Kevin VanGelder <kevin.vangelder1@accesscfa.com> Co-authored-by: Alex Hernandez <oorangecchicken@gmail.com> Co-authored-by: Kudo Chien <ckchien@gmail.com> Co-authored-by: Laurent Gaches <laurent@l18.dev> Co-authored-by: Mehrdad Moradi <me@mmoradi.ca> Co-authored-by: Mike Hardy <github@mikehardy.net> Co-authored-by: Wanderson Alves <wandersonalwes@hotmail.com> Co-authored-by: Jakub Piasecki <jakubpiasecki67@gmail.com> Co-authored-by: John Kennedy Mumo <jfkenmumo@hotmail.com> Co-authored-by: Kennedy Mumo <kemumo@microsoft.com> Co-authored-by: David Sharp <hello@davidsharp.codes> Co-authored-by: Ivan Suslov <digitalzuzel@gmail.com> Co-authored-by: Sungyu Kang <gron1gh1@gmail.com> Co-authored-by: Vijay Bindraban <2269400+VMBindraban@users.noreply.github.com> Co-authored-by: Caspian Zhao <caspian.zhao@outlook.com> Co-authored-by: Ryo Kuramoto <dekachan16@gmail.com>
Why
possible solution for #2771
How
observations:
the crash is from https://android.googlesource.com/platform/frameworks/base/+/f05f9b960832b6272b6740721c0a4bbd1ce632c1/libs/hwui/pipeline/skia/GLFunctorDrawable.cpp#95 which looks like for WebView to draw something on offscreen buffer because it hits the view boundary.
the
MakeRenderTarget()
returns null becauseSK_SUPPORT_GPU is undefined in skia build.the offscreen surface size is 0, i.e.!imageInfo.width() || !imageInfo.height()
I could confirm it returns null by attaching debugger. https://android.googlesource.com/platform/external/skia/+/be52e9ba4d0a3c1e27c2ac215ddb14ab2b72274b/include/core/SkSurface.h#337modern devices should use skia vulkan (skiavk) renderer for hwui. supposedly it will not crash. i.e.
adb shell getprop ro.hwui.use_vulkan
returns true andadb shell getprop debug.hwui.renderer
returns nothing.the call path happens only on hwui skiagl render type. it is the default setting for emulator on my mac m1.
adb shell getprop debug.hwui.renderer
returns skiagl for me.i could also reproduce the crash on devices by forcing hwui skiagl mode:
adb shell setprop debug.hwui.renderer skiagl
.from the crash stacktrace, i could see
android::uirenderer::skiapipeline::RenderNodeDrawable::forceDraw()
. it might also be a root cause where android should not call forceDraw at this point.since it's offscreen only, i could also reproduce the crash from a single webview example.
tried to rewrite the above example in android native code without react-native. it works fine without crashes for me. my hypothesis is that the reason to trigger forceDraw should be somewhere in react-native. finally get the code in ReactViewGroup which clip the canvas and it may come with side effects for webview compositing.
then the question is "how could we create a dedicated android canvas for webview?" the answer in this pr is to wrap a webview inside a FrameLayout.
this pr basically updates the view hierachy to have
Test Plan