-
Notifications
You must be signed in to change notification settings - Fork 1k
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
bug: MessageHandler usage of JavaScriptReplyProxy is triggering a native crash on webview #5949
Comments
This issue may need more information before it can be addressed. In particular, it will need a reliable Code Reproduction that demonstrates the issue. Please see the Contributing Guide for how to create a Code Reproduction. Thanks! |
@jcesarmobile, sorry for my late reply. Is really hard for us to provide a sample app as there is a proprietary login SDK also involved and we cannot share this. In our team, we think the problem might be related to that when a user is logging in / out, this login SDK opens another WebView. After the process is finished, a capacitor plugin notifies the web content (hosted on the main WebView) that the page needs to be reloaded. Is there any other way to proceed with this issue? |
There is no way to proceed if we can't reproduce. |
But the crash doesn't happen on the login SDK, but on the main WebView. |
then you can provide a sample app where the crash still happens but the SDK is not involved. |
I have an idea, would it be possible to make the above change something that can be turned on / off by a new flag in CapConfig? |
I've added this as feature request to allow to use the old bridge. Also using the old bridge is more insecure and google could remove it at any time while the new one is more future proof. |
I see the same problem in production, it appeared after upgrading to capacitor 4. However, I'm also not able to reproduce the issue as I have no idea under which circumstances it appears (unfortunately for this issue Sentry error logs don't contain any information on what happened before the crash). |
Hi @hermitdemschoenenleben, |
May or may not be relevant here... but I get a crash like this when using a plugin that needs a dangerous Android permission, and attempting to invoke this immediately during start up. In my specific case, I'm using cordova-plugin-ble-central, and invoking a scan on app launch. A scan requires the user to allow location permissions via a system dialogue. I found that I had to put a small delay (e.g. 500ms) before starting the scan, as otherwise the permission request gets stuck in an infinite loop. In my case, it's because the plugin permissions response gets called with an empty permissions collection that has no granted or denied permissions, which causes the ble plugin to immediately make another permissions request. The infinite recursion eventually crashes the browser in a second or two during launch. Apologies if this is unrelated to the issue here... Just adding the comment in case it's a useful hint. |
@Charchad ok, thanks a lot! I'll try it out then by forking capacitor and replacing these lines. @peitschie thanks a lot for sharing your insight! At least for my app, this doesn't seem to be the cause of the problem though as I don't request dangerous android permissions on app start |
Is there any update of when this new flag to toggle between the old/new bridge will be added? @hermitdemschoenenleben, forking Capacitor solved your crashes? |
There has been another similar issue reported and the problem there is that the new bridge runs plugins in main thread while the old bridge uses a background thread.
|
Hi @jcesarmobile, I just tried your suggested change but I'm afraid the crash still happens. |
@Charchad I'm rolling out a new version that includes the fix of your first post and this seems to fix the crash. As we have a tight schedule right now, I won't be able to test jcesarmobile's fix for the next few weeks, though. |
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out. |
Bug Report
Capacitor Version
@capacitor/cli: 4.1.0
@capacitor/android: 4.1.0
@capacitor/ios: 4.1.0
@capacitor/core: 4.1.0
Platform(s)
Android
Current Behavior
For some reason the app crashes when the webview is under stress, triggering a native crash:
I have changed the app package id for security reasons.
Expected Behavior
The app shouldn't crash
Code Reproduction
The crash is not triggered anymore if the change that was made on sendResponseMessage is reverted:
Now (Doesn't Work):
Before (Works):
So I guess something is wrong with this call:
Other Technical Details
The crash doesn't happen with Capacitor 3.8.0 but still happens with Capacitor 4.3.0
npm --version
output:8.1.0
node --version
output:v16.13.0
The text was updated successfully, but these errors were encountered: