Skip to content
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

Android BorrowError panic in wry and inability to restart/launch #1420

Open
tristan-morris opened this issue Nov 18, 2024 · 19 comments
Open

Comments

@tristan-morris
Copy link

tristan-morris commented Nov 18, 2024

Describe the bug
I'm attempting to run Tauri on an existing prod React project. I have been encountering a panic somewhat reliably after a deep-link is called (user goes to complete oauth flow, deep-link drops them back in the app successfully - this works great). However, on next app launch it seems like the deep-link state is still present and causes a panic. This panic is then irrecoverable. Force-quit the tauri app = panic. Try and force-quit again and panic. App is then dead mostly. Sometimes it will come back, as if a bad event has been dispatched successfully. Delete the app from the device and it can be reliably installed.

I have been able to cause the same set of panics with a similar flow - when there's competition for launching the WebKitClient(?).

I haven't made much more progress on this issue but happy to keep looking into it.

Steps To Reproduce

  • Install Tauri
  • Install deep-link plugin (may not entirely be necessary - I've caused it other ways but this seems semi reliable)
  • Configure a deep link
  • Trigger a deep-link to arrive back in app
  • Close the app (kill)
  • Re-launch the app.

Expected behavior
No panic.

Screenshots
Panic:
image

References:
image

Platform and Versions (please complete the following information):
OS: Android on Pixel 4a 5G. I am port forwarding from the Android device to my dev PC.
Rustc: 1.82

Additional context

Logcat Output during the panic (nothing useful beyond the reference to unwinding panic):

...snip...
11-17 08:26:34.924 18908 18908 F DEBUG   :       #08 pc 00000000015c3db8  /data/app/~~XWb8Z89T6mNxIkk6s7bm2A==/io.testy.ui-7cAR2kQUjsQd7GVdttgacA==/base.apk (offset 0x5e8000) (core::panicking::panic_cannot_unwind::he22847d5ac2210b8+20)
11-17 08:26:34.924 18908 18908 F DEBUG   :       #09 pc 0000000000a1c4d8  /data/app/~~XWb8Z89T6mNxIkk6s7bm2A==/io.testy.ui-7cAR2kQUjsQd7GVdttgacA==/base.apk (offset 0x5e8000) (Java_io_testy_ui_RustWebViewClient_withAssetLoader+36)
11-17 08:26:34.924 18908 18908 F DEBUG   :       #10 pc 0000000000384370  /apex/com.android.art/lib64/libart.so (art_quick_generic_jni_trampoline+144) (BuildId: 3f7d5a016e08d528f129bdd336d81168)

Full Logcat output: https://gist.github.com/tristan-morris/44dd5f7e451f6f81d260c7a56b14afa4

$ cargo tauri info

[✔] Environment
- OS: Ubuntu 23.4.0 x86_64 (X64)
✔ webkit2gtk-4.1: 2.42.4
✔ rsvg2: 2.54.5
✔ rustc: 1.82.0 (f6e511eec 2024-10-15)
✔ cargo: 1.82.0 (8f40fc59f 2024-08-21)
✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
✔ Rust toolchain: stable-x86_64-unknown-linux-gnu (environment override by RUSTUP_TOOLCHAIN)
- node: 21.5.0
- yarn: 1.22.21
- npm: 10.2.4

[-] Packages
- tauri 🦀: 2.1.1
- tauri-build 🦀: 2.0.3
- wry 🦀: 0.47.0
- tao 🦀: 0.30.8
- tauri-cli 🦀: 2.1.0
- @tauri-apps/api : 2.1.1
- @tauri-apps/cli : 2.1.0

[-] Plugins
- tauri-plugin-log 🦀: 2.0.2
- @tauri-apps/plugin-log : not installed!
- tauri-plugin-notification 🦀: 2.0.1
- @tauri-apps/plugin-notification : 2.0.0
- tauri-plugin-shell 🦀: 2.0.2
- @tauri-apps/plugin-shell : 2.0.1
- tauri-plugin-geolocation 🦀: 2.0.1
- @tauri-apps/plugin-geolocation : 2.0.0
- tauri-plugin-deep-link 🦀: 2.0.1
- @tauri-apps/plugin-deep-link : 2.0.0
- tauri-plugin-fs 🦀: 2.0.3
- @tauri-apps/plugin-fs : 2.0.2

[-] App
- build-type: bundle
- CSP: unset
- frontendDist: ../dist
- devUrl: http://localhost:3000/
- framework: React
- bundler: Rollup

@nic96
Copy link

nic96 commented Nov 18, 2024

I'm getting a similar error. I'm using MapLibre GL JS in tauri on android and occasionally while zooming/panning around in the map I get a crash:

11-18 16:02:05.774 28302 28340 I RustStdoutStderr: thread '<unnamed>' panicked at /home/nic96/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wry-0.47.1/src/android/binding.rs:109:42:
11-18 16:02:05.774 28302 28340 I RustStdoutStderr: already mutably borrowed: BorrowError
11-18 16:02:05.774 28302 28340 I RustStdoutStderr: note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
11-18 16:02:05.775 28302 28340 I RustStdoutStderr: thread '<unnamed>' panicked at /home/nic96/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wry-0.47.1/src/android/binding.rs:109:42:
11-18 16:02:05.775 28302 28340 I RustStdoutStderr: already mutably borrowed: BorrowError
11-18 16:02:05.776 28302 28340 I RustStdoutStderr: thread '<unnamed>' panicked at library/core/src/panicking.rs:221:5:
11-18 16:02:05.776 28302 28340 I RustStdoutStderr: panic in a function that cannot unwind
11-18 16:02:05.776 28302 28340 I RustStdoutStderr: stack backtrace:
...

@tristan-morris
Copy link
Author

Interesting! Thanks for the report as it helped confirm my sanity.

I'm using Mapbox Gl Js so it could relate somehow. As a counter point, I haven't had any crashes (past hour or two) when dev'ing on my Mac M1, but my much more performant PC panics.

@tdomhan
Copy link

tdomhan commented Dec 28, 2024

This is probably related to: #1379

@tristan-morris
Copy link
Author

Thanks for confirming! I moved to capacitorjs after making no progress.

@Maxou44
Copy link

Maxou44 commented Jan 4, 2025

I have the same issue, the first launch work, but an app relaunch randomly crash.

This is my logs : Tauri-crash.log

@tracy-codes
Copy link

We are encountering this exact same issue.

@hongfanmeng
Copy link

When in dev mode, the app will open successfully only once every 5 times, and the remaining 4 times will crash due to this reason

@Maxou44
Copy link

Maxou44 commented Jan 30, 2025

Does anyone know how to fix this bug? It's blocking me from building an Android app using Tauri. 😰

@hongfanmeng
Copy link

Downgrading the wry version to 0.46.1 appears to resolve the bug. Below is the updated Cargo.toml file

[dependencies]
tauri = { version = "=2.0.6", features = [] }
tauri-runtime-wry = "=2.1.2"
tauri-runtime = "=2.1.1"

@alexiokay
Copy link

doesn't work for me with latest tauri version. ( I won't downgrade )

@Vexcited
Copy link

Any ETA on this ? My app is crashing on production for Android users because of this issue. My Play Console reports dozens of crashes every hour for this specific issue (it's always the same error and logs).

@FabianLars
Copy link
Member

No ETA. Some reproduction examples/steps, or at least some kind of descriptions on where/when this happens in your app would probably help. Afaik we haven't been able to reproduce this in latest tauri/wry anymore (iirc #1505) but not sure (i don't have a working dev env until next week or so, so can't confirm myself - not that i was ever able to repro it lol)

@Vexcited
Copy link

I am running on wry 0.49, I'll try to bump to latest to have this fix and will tell if it fixed the issue for me or not! If you want more details, I have an FCM service running for push notifications on Android and that's all. When I did not have it, it did not crash. Thanks for the quick response, will try it out !

@tdomhan
Copy link

tdomhan commented Mar 16, 2025

Is it possible this is related to this bug #1379 ?

@caipeter888
Copy link

I had the same issue.

In dev mode, if I do not close the Android app, just use Ctrl+C to interrupt debugging on PC, and then re-execute tauri android dev, there is a high probability that this problem will occur.

thread '<unnamed>' panicked at D:\path\to\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\wry-0.48.1\src\android\binding.rs:109:42:
already mutably borrowed: BorrowError
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

thread '<unnamed>' panicked at library/core/src/panicking.rs:218:5:
panic in a function that cannot unwind

@FabianLars
Copy link
Member

that's also an outdated wry version (0.48) so basically irrelevant until someone sees it on 0.50.x as well

@NyaomiDEV
Copy link

I can say I am probably facing the same issue, but without even using the deep-link plugin.

Basically, my app only starts once after it's installed; for any subsequent steps it hangs indefinitely until an ANR popup appears.

The app in question is https://github.com/NyaomiDEV/Ampersand. The error happens on both builds produced by GH Actions as well as local builds.

@Vexcited
Copy link

Afaik we haven't been able to reproduce this in latest tauri/wry anymore (iirc #1505) but not sure (i don't have a working dev env until next week or so, so can't confirm myself - not that i was ever able to repro it lol)

wry 0.50 definitely fixed the issue for me, I'm back to 0% crash in the Play Console reports and I'm not getting anymore crash in development neither ! Thanks you !

@Vexcited
Copy link

Vexcited commented Mar 19, 2025

I'm running under 0.50.5, see https://github.com/Vexcited/StayReal/blob/39026d86fa7e487bb94f7dc8e3d9d9704805e663/src-tauri/Cargo.toml#L31-L32

I have a small patch for the Kotlin code because my app needs to do some tweaks about HTTP requests...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests