WebView reloading after taking photo with Capacitor Camera Plugin

Hi everyone!

I experienced an issue with my App on an iPhone 8. The WebView does reload sometimes, when I use Capacitors Camera getPhoto function. This seems to happen more often, if I have some more apps open in background.

Some more infos I found out:

  • webViewWebContentProcessDidTerminate gets called to reload the view

Xcode logs before webViewWebContentProcessDidTerminate does get called:

[ProcessSuspension] 0x10d2d42d0 - ProcessAssertion::processAssertionWasInvalidated()**
[ProcessSuspension] 0x10d2d4300 - ProcessAssertion::processAssertionWasInvalidated()**
[assertion] Error acquiring assertion: <NSError: 0x2833e7630; domain: RBSAssertionErrorDomain; code: 2; reason: "Specified target process does not exist">**
[assertion] Error acquiring assertion: <NSError: 0x2833dc3c0; domain: RBSAssertionErrorDomain; code: 2; reason: "Specified target process does not exist">**

I hope someone can help me with this.

That suggests to me that it’s a resource starvation issue, which if true would place it squarely outside of the locus of control of your app. The phone is killing things in order to free up memory.

Thank you for the response, it does make sense.

Is there a way to detect whats causing this issue or do i have to check my code for things like memory leaks?

I do have more logs or code if needed.

Are you using result type of Uri or base64? base64 can cause performance/memory issues on lower end devices, so we recommend Uri. See our First App example here for a real implementation.

1 Like

Yes, I’m using Uri instead of base64 like this:

Plugins.Camera.getPhoto({
    quality: 40,
    allowEditing: false,
    resultType: CameraResultType.Uri,
    saveToGallery: false,
    source: CameraSource.Camera
})

This is also the last thing I call from my JavaScript code before the native camera view is shown. I can see the WebView reloading in my Xcode and Safari logs, right after i take the photo or just after pressing “Use Photo”.

Some context: The user of my app needs to take 8 photos in total, but the WebView keeps reloading sometimes and I need to retake the photo after that happens. I didn’t have this problem with my cordova apps.

I did some research and it seems like this is the same problem here: https://github.com/ionic-team/capacitor/issues/2265.

1 Like