⚠️ Heads up: Trichrome / WebView random crashes on Camera.getPhoto() on Android

Hey everyone,

we’ve been battling a nasty crash in our Ionic + Capacitor 7 app, that’s been tanking our otherwise flawless crash rate on Google play. I figured I’d post this here in case it saves someone else the headache.

The issue

  • On Android, when using the @capacitor/Camera plugin and calling Camera.getPhoto() (or similar APIs that spin up the WebView renderer), some users hit hard native crashes inside the TrichromeLibrary (libmonochrome_64.so).

  • The crash originates from the system’s Android System WebView / Chrome Trichrome package, so it’s not something we as app devs directly control.

  • In Google Play Console, these show up as com.google.android.trichromelibrary crashes and can wreck your crash-free stats (Google even threatens reduced visibility if your crash rate is high).

What we found

  • It’s not tied to Capacitor or Ionic versions specifically (we saw it even after updating everything to Capacitor 7).

  • It’s caused by bugs in certain Trichrome / WebView releases.

  • It’s random and device-dependent, which makes it extra frustrating.

Workarounds / Mitigation

  • Explicitly include the latest androidx.webkit in app/build.gradle so you’re not stuck on an older system default:

    implementation "androidx.webkit:webkit:1.12.1"
    
    
  • Ideally add a WebView listener to catch renderer process deaths instead of letting the whole app die.

  • Add a cooldown on reloads to avoid endless crash loops.

  • Things to note - reload in MainActivity doesn’t work, the activity becomes too corrupted, same with recreate … the only thing that helped was killing the process and a complete hard restart

  • But honestly in the end, just like us, you will probably have to migrate from a plugin that opens a new intent to open the camera to a plugin that just opens the camera in your own MainActivity‘s intent (we went with @capgo/camera-preview)

Reality check

This seems to be a Google WebView/Trichrome bug. It does not happen on iOS it has something to do with opening the new intent for the camera, it seems like the process starts running low on memory and just crashes. Despite many many efforts to downscale images and not perform anything memory heavy in our code, it would randomly crash again and again. It does not happen for opening gallery, only for taking an image. It seems like the intent handoff just sometimes doesn’t happen right, the camera always would open but then coming back - changing intents and properly closing, that’s where u crash.

What we had to do eventually

For android image capture we had to implement @capgo/camera-preview as that one doesn’t open new intent and just runs in your already created activity. That seemed to have fixed the issue but obviously it’s not ideal as now we have to maintain two approaches.


:backhand_index_pointing_right: If you’ve seen similar crashes in your app, you’re not alone. Hopefully Google stabilizes Trichrome soon, but until then, these mitigations can help and save your Play Store stats.

1 Like

Hello, my name is Michael and I work at Capgo. Google’s WebView can be quite annoying when it comes to random crashes. I have seen it personally in one of the apps of our client, and it can be quite a hassle to debug and to fix. Could you please tell me the reason for which you are not willing to fully switch to @capgo/camera-preview on both iOS and Android?

Hello, honestly because of the need to design the camera interface. Capacitor camera plugin opens the built in camera interface with all the options u would normally have when using the Camera app. Whereas @capgo/camera-preview needs me to design the whole thing. So to quickly fix and deploy it (and prevent further damage to my ratings) I just designed a simple one for android with 4:3 aspect ratio and optional flash button… but decided to keep the full one at least for iOS where these errors do not seem to happen at all.

UPDATE btw: this fix did indeed work, we have 0 crashes from the time of deployment