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

Screen flashes white on function call, and "discovery" error #462

Closed
3 tasks done
willnix86 opened this issue Jun 16, 2019 · 5 comments
Closed
3 tasks done

Screen flashes white on function call, and "discovery" error #462

willnix86 opened this issue Jun 16, 2019 · 5 comments

Comments

@willnix86
Copy link

willnix86 commented Jun 16, 2019

#425
Bug Report

Problem

When I fire off the function to select an image from the camera roll, the device screen flashes white and pauses slightly before opening the camera roll.

The pause is less with each press, but the flashing white screen still occurs - judging by my console logs, whenever I fire off the getCamera function, the app is being re-initialized (see screenshot - 'Open DB' should only be happening on app init.

The camera roll does load, but when I select an image, I receive the following error:

[discovery] errors encountered while discovering extensions: Error Domain=PlugInKit Code=13 "query cancelled" UserInfo={NSLocalizedDescription=query cancelled}

Initially, I wasn't receiving a permissions request for the camera roll so I had to wrap the function in a cordova.diagnostic request function, so now I KNOW permission to access the camera roll is granted.

What is expected to happen?

The camera roll prompt loads without a visual error and I can access the picture in the functions success callback.

What does actually happen?

See problem above ^^^

Information

Happens on both emulated and physical devices

Screen Shot 2019-06-15 at 8 34 51 PM

Command or Code

handleCameraRollPermission is fired from an onClick event

function handleCameraRollPermission() {
  window.cordova.plugins.diagnostic.getCameraRollAuthorizationStatus(status => {
    switch (status) {
      case window.cordova.plugins.diagnostic.permissionStatus.NOT_REQUESTED:
        window.cordova.plugins.diagnostic.requestCameraRollAuthorization(status => 
          status === window.cordova.plugins.diagnostic.permissionStatus.GRANTED &&
            addImage(), 
          err => console.log('Camera roll request error ' + err));
        break;
      case window.cordova.plugins.diagnostic.permissionStatus.DENIED:
          console.log("Permission denied");
          break;
      case window.cordova.plugins.diagnostic.permissionStatus.GRANTED:
          addImage();
          break;
      default:
        break;
    } 
  }, function(error){
      console.error("The following error occurred: "+error);
  });
}

function addImage() {
  navigator.camera.getPicture(imageURI => {
    console.log(imageURI);
  }, err => {
    console.log(err);
  }, {
    sourceType: window.Camera.PictureSourceType.PHOTOLIBRARY
  });
}

Environment, Platform, Device

Physical iPhone 6s - iOS 12.4
Simulated iPhone Xr - iOS 12.2

Version information

"cordova-android": "^8.0.0",
"cordova-android-firebase-gradle-release": "^3.0.0",
"cordova-android-play-services-gradle-release": "^3.0.0",
"cordova-browser": "^6.0.0",
"cordova-custom-config": "^5.1.0",
"cordova-ios": "^5.0.1",
"cordova-plugin-camera": "^4.0.3",
"cordova-plugin-device": "^2.0.2",
"cordova-plugin-whitelist": "^1.3.3",
"cordova-plugin-wkwebview-engine": "^1.1.4",
"cordova-sqlite-storage": "3.2.0",
"cordova.plugins.diagnostic": "4.0.12",
"react": "^16.8.6"

Xcode 10.2.1
Mac OS X Mojave

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above
@willnix86
Copy link
Author

Weirdly it works as it should if I call the navigator.camera.getPicture function from the console in Safari when it's set up to point to the app on my iPhone, just not if I call the function from within the app. If that helps at all...

@willnix86
Copy link
Author

Figured this out - it's because I had the button inside a form face-palm

@janpio
Copy link
Member

janpio commented Jul 13, 2019

Any insight how this influences it?

@willnix86
Copy link
Author

I wish I had more expert insight, but I can only guess that because the button is inside a form with "method=POST" assigned to it, despite the fact that there's a 'submit' button at the bottom of the form, said form treats this other button as a submit button too, so it fires the post method, which refreshes the app for whatever reason, breaking the plugin function.

I could be totally wrong about what was happening, but I know that moving the 'add image' button outside of the form fixed it - I figured it out because the same 'white flash' was happening even if the function just logged to the console.

@breautek
Copy link
Contributor

stale

@breautek breautek closed this as not planned Won't fix, can't repro, duplicate, stale Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants