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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Camera.getPhoto() randomly crashes the application on iOS and Android #1887

Open
corentincouq opened this issue Nov 7, 2023 · 2 comments
Open

Comments

@corentincouq
Copy link

corentincouq commented Nov 7, 2023

Bug Report

Plugin(s)

"@capacitor/camera": "5.0.7"

Capacitor Version

馃拪   Capacitor Doctor  馃拪 

Latest Dependencies:

  @capacitor/cli: 5.5.1
  @capacitor/core: 5.5.1
  @capacitor/android: 5.5.1
  @capacitor/ios: 5.5.1

Installed Dependencies:

  @capacitor/android: 5.5.1
  @capacitor/ios: 5.5.1
  @capacitor/cli: 5.5.1
  @capacitor/core: 5.5.1

[success] iOS looking great! 馃憣
[success] Android looking great! 馃憣

Platform(s)

iOS 17
Android 13
And probably other versions

Current Behavior

When I use the getPhoto() function, my application crashes randomly.

The crash occurs randomly on the same photo, whether in the gallery or with the camera.

This causes the application to crash or nothing works any more, as if we were in an infinite loop.

It is impossible to catch an error or stop the process without killing the application.

Expected Behavior

I'd like to be able to retrieve the response from getPhoto() or at least prevent the process from crashing, making my application unusable.

Code Reproduction

I have two functions used in this process :

export async function recuperePhoto(sourcePhoto: 'camera' | 'photos') {
  const source = sourcePhoto === 'camera' ? CameraSource.Camera : CameraSource.Photos;
  const photoRecuperer: Photo = await Camera.getPhoto({
    resultType: CameraResultType.Base64,
    source,
    quality: 50,
  });

  const photoEnregistrer = await enregistreImage(photoRecuperer);
  return photoEnregistrer.data;
}

async function enregistreImage(fichier: Photo) {
  if (fichier.base64String != null) {
    const base64Data = `data:image/${fichier.format};base64,${fichier.base64String}`;
    return { data: base64Data };
  }
  return { data: undefined };
}

If I try to modify the code to catch an error like this :

export async function recuperePhoto(sourcePhoto: 'camera' | 'photos') {
  const source = sourcePhoto === 'camera' ? CameraSource.Camera : CameraSource.Photos;

  try {
    const photoRecuperer: Photo = await Camera.getPhoto({
      resultType: CameraResultType.Base64,
      source,
      quality: 50,
    });
  } catch(error) {
    console.log(error)
  }

  const photoEnregistrer = await enregistreImage(photoRecuperer);
  return photoEnregistrer.data;
}

my application will always crash without being able to catch an error or stop the process

Other Technical Details

"@ionic/vue": "^6.7.5"
"vue": "3.3.8"

We also use Sentry for capacitor, which is also unable to catch any errors.
"@sentry/capacitor": "0.14.0"

Additional Context

This bug is completely random and seems to come from the native code launched by getPhoto() on the most recent phones. We do not generate the error on the iOS simulator.

@jpolo
Copy link

jpolo commented Nov 15, 2023

I have the problem, it does not seems to crash but the phone is heating and the app is not responding.
It seems to be reproducible when I uninstall/reinstall the app and try to take a photo.

@jpike88
Copy link

jpike88 commented May 6, 2024

Some someone pls post an error pls? Breakpoint on uncaught exceptions in xcode

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

4 participants