ionic-team / capacitor-plugins

Official plugins for Capacitor ⚡️
512 stars 581 forks source link

Camera (capacitor 3 @capacitor/camera) pickImages() doesn't work the first time #702

Closed Trallo closed 2 years ago

Trallo commented 2 years ago

Bug Report

Plugin(s)

Camera v1.2.1

Capacitor Version

Latest Dependencies:

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

Installed Dependencies:

  @capacitor/cli: 3.2.2
  @capacitor/android: 3.2.2
  @capacitor/ios: 3.2.2
  @capacitor/core: 3.3.1

Platform(s)

Android

Current Behavior

After calling Camera.pickImages, I don't get neither any response nor any error. This happens only for the first time. Second time onwards it works fine

Expected Behavior

pickImages() method should work the first time as well

Code Reproduction

const options: GalleryImageOptions = { quality: 60, limit: this.maxImgsCount };

        Camera.pickImages(options).then(
            (results: GalleryPhotos) => {
                if (results && results.photos) {
                    this.onNewImagesAdd(results.photos);
                }
            },
            err => {
                console.error('Error clicking a picture');
            }
        );

Other Technical Details

Additional Context

dksanket commented 2 years ago

I am also facing the same issue

jcesarmobile commented 2 years ago

I can't reproduce, can you provide a sample app?

Also, can you provide more information about the devices where you tested? Real device or emulator? Android version? Vendor? model?

dksanket commented 2 years ago

Hi @jcesarmobile , thank you for such a quick response. Please find my device details below Real device or emulator? - Real device Android version? - 9 Vendor? - Redmi model? - Redmi Note 8

jcesarmobile commented 2 years ago

Just tested on a Redmi Note 8 with Android 9 and I couldn't reproduce. Can you provide a sample app? Do you see something in logcat?

dksanket commented 2 years ago

Hi @jcesarmobile , give me few days of time, I will try to provide a sample app.. Thank you so much again for looking into it..

dksanket commented 2 years ago

I created a sample app but there it is working fine.. I added almost all the dependencies from the app where it is not working to this sample app and tested, still it works, so something is wrong in my app itself, I will investigate more and get back to you @jcesarmobile . Thank you for your time.

ghonche commented 2 years ago

I created a sample app but there it is working fine.. I added almost all the dependencies from the app where it is not working to this sample app and tested, still it works, so something is wrong in my app itself, I will investigate more and get back to you @jcesarmobile . Thank you for your time.

Did you find what is wrong with your app? I'm facing the same issue. @dksanket

dksanket commented 2 years ago

I created a sample app but there it is working fine.. I added almost all the dependencies from the app where it is not working to this sample app and tested, still it works, so something is wrong in my app itself, I will investigate more and get back to you @jcesarmobile . Thank you for your time.

Did you find what is wrong with your app? I'm facing the same issue. @dksanket

No @ghonche. I tried for 2-3 days , couldn't fix it. Will try more maybe this week or next week. Please let me know if you find any solution meanwhile.

ghonche commented 2 years ago

Let's find out what we have in common in our projects! For example what plugins are you using? @dksanket

dksanket commented 2 years ago

Let's find out what we have in common in our projects! For example what plugins are you using? @dksanket

Please find it below

"dependencies": { "@angular/animations": "^11.2.9", "@angular/cdk": "^11.2.9", "@angular/cli": "^11.2.9", "@angular/common": "^11.2.9", "@angular/core": "^11.2.9", "@angular/fire": "^5.2.1", "@angular/forms": "^11.2.9", "@angular/platform-browser": "^11.2.9", "@angular/platform-browser-dynamic": "^11.2.9", "@angular/router": "^11.2.9", "@angular/service-worker": "^11.2.9", "@awesome-cordova-plugins/core": "^5.37.2", "@awesome-cordova-plugins/launch-navigator": "^5.37.3", "@capacitor-community/admob": "^3.2.0", "@capacitor-community/contacts": "^1.0.9", "@capacitor/android": "^3.3.3", "@capacitor/app": "^1.0.3", "@capacitor/camera": "^1.2.2", "@capacitor/core": "3.3.3", "@capacitor/device": "^1.0.3", "@capacitor/filesystem": "^1.0.3", "@capacitor/geolocation": "^1.1.0", "@capacitor/haptics": "^1.0.3", "@capacitor/ios": "^3.2.2", "@capacitor/keyboard": "^1.0.3", "@capacitor/network": "^1.0.3", "@capacitor/push-notifications": "^1.0.4", "@capacitor/share": "^1.0.4", "@capacitor/splash-screen": "^1.1.2", "@capacitor/status-bar": "^1.0.3", "@capacitor/storage": "^1.2.3", "@ionic-native/android-permissions": "^5.33.1", "@ionic-native/app-rate": "^5.31.1", "@ionic-native/call-number": "^5.33.0", "@ionic-native/core": "^5.0.0", "@ionic-native/diagnostic": "^5.28.0", "@ionic-native/facebook": "^5.28.0", "@ionic-native/file-transfer": "^5.28.0", "@ionic-native/firebase-x": "^5.26.0", "@ionic-native/google-maps": "^5.0.0-beta.27", "@ionic-native/google-plus": "^5.28.0", "@ionic-native/image-picker": "^5.28.0", "@ionic-native/instagram": "^5.28.0", "@ionic-native/native-geocoder": "^5.32.0", "@ionic-native/photo-library": "^5.28.0", "@ionic-native/sms-retriever": "^5.28.0", "@ionic-native/social-sharing": "^5.28.0", "@ionic-native/splash-screen": "^5.28.0", "@ionic-native/sqlite": "^5.28.0", "@ionic-native/sqlite-porter": "^5.28.0", "@ionic/angular": "^5.7.0-dev.202104232151.a9018a2", "@ionic/pwa-elements": "^3.0.1", "@ngrx/effects": "^11.1.0", "@ngrx/entity": "^11.1.0", "@ngrx/router-store": "^11.1.0", "@ngrx/store": "^11.1.0", "@ngrx/store-devtools": "^11.1.0", "@types/google-maps": "^3.2.1", "@types/googlemaps": "^3.36.6", "angularfire2": "^5.2.1", "call-number": "^1.0.1", "cordova-android": "^8.1.0", "cordova-androidx-build": "^1.0.4", "cordova-browser": "6.0.0", "cordova-instagram-plugin": "^0.5.8", "cordova-plugin-actionsheet": "^2.3.3", "cordova-plugin-android-permissions": "^1.1.2", "cordova-plugin-androidx": "^3.0.0", "cordova-plugin-androidx-adapter": "^1.1.0", "cordova-plugin-apprate": "^1.7.2", "cordova-plugin-contacts": "^3.0.1", "cordova-plugin-dialogs": "^2.0.2", "cordova-plugin-facebook4": "^6.4.0", "cordova-plugin-file": "^6.0.2", "cordova-plugin-file-transfer": "^1.7.1", "cordova-plugin-googlemaps": "git+https://github.com/mapsplugin/cordova-plugin-googlemaps.git#multiple_maps", "cordova-plugin-googleplus": "^8.5.0", "cordova-plugin-nativegeocoder": "^3.4.1", "cordova-plugin-photo-library": "^2.3.1", "cordova-plugin-sms-receive": "^1.0.2", "cordova-plugin-sms-retriever-manager": "^1.0.2", "cordova-plugin-telerik-imagepicker": "^2.3.3", "cordova-plugin-x-socialsharing": "^6.0.1", "cordova-res": "^0.8.1", "cordova-sms-plugin": "^1.0.1", "cordova-sqlite-storage": "^5.0.1", "cordova-universal-clipboard": "git+https://github.com/Visigo/CordovaClipboard.git", "cordova.plugins.diagnostic": "^5.0.2", "core-js": "^2.5.4", "es6-promise-plugin": "^4.2.2", "firebase": "^6.5.0", "font-awesome": "^4.7.0", "intl-tel-input": "^17.0.8", "lodash": "^4.17.15", "net": "^1.0.2", "ng2-tel-input": "^2.3.0", "node-gyp": "^7.0.0", "node-sass": "^4.14.1", "primeicons": "^1.0.0", "primeng": "^9.0.6", "quill": "^1.3.6", "rxjs": "~6.6.7", "sass-loader": "^6.0.7", "sockjs-client": "^1.5.0", "stompjs": "^2.3.3", "tippy.js": "^6.2.3", "tslib": "^2.0.0", "uk.co.workingedge.cordova.plugin.sqliteporter": "^1.1.1", "uk.co.workingedge.phonegap.plugin.launchnavigator": "^5.0.6", "zone.js": "~0.11.4" }, "devDependencies": { "@angular-devkit/architect": "^0.1102.9", "@angular-devkit/build-angular": "^0.1102.9", "@angular-devkit/core": "^11.2.9", "@angular-devkit/schematics": "^11.2.9", "@angular/compiler": "~11.2.9", "@angular/compiler-cli": "~11.2.9", "@angular/language-service": "~11.2.9", "@capacitor/cli": "3.3.3", "@ionic/angular-toolkit": "^2.2.0", "@ionic/lab": "2.0.5", "@ngrx/schematics": "^11.1.0", "@types/jasmine": "~3.6.0", "@types/jasminewd2": "~2.0.3", "@types/lodash": "^4.14.149", "@types/mocha": "^9.0.0", "@types/node": "~12.0.0", "codelyzer": "^6.0.0", "jasmine-allure-reporter": "^1.0.2", "jasmine-core": "~3.6.0", "jasmine-reporters": "2.2.1", "jasmine-spec-reporter": "~5.0.0", "jetifier": "^1.6.8", "karma": "~6.3.2", "karma-chrome-launcher": "~3.1.0", "karma-coverage-istanbul-reporter": "~3.0.2", "karma-jasmine": "~4.0.0", "karma-jasmine-html-reporter": "^1.5.0", "mocha": "^9.0.0", "prettier": "^2.0.2", "protractor": "~7.0.0", "ts-node": "~8.3.0", "tslint": "~6.1.0", "typescript": "4.1.5" }, "description": "An Ionic project", "cordova": { "plugins": { "cordova-plugin-googlemaps": { "PLAY_SERVICES_VERSION": "15.0.1", "ANDROID_SUPPORT_V4_VERSION": "27.+" }, "cordova.plugins.diagnostic": { "ANDROID_SUPPORT_VERSION": "28.+" } }, "platforms": [ "android", "browser" ] }

ghonche commented 2 years ago

Seems we have these in common: @dksanket

{ "@angular/animations": "^13.1.1", "@angular/common": "~13.1.1", "@angular/core": "~13.1.1", "@angular/fire": "^7.2.0", "@angular/forms": "~13.1.1", "@angular/platform-browser": "~13.1.1", "@angular/platform-browser-dynamic": "~13.1.1", "@angular/router": "~13.1.1", "@angular/service-worker": "~13.1.1", "@awesome-cordova-plugins/core": "^5.37.3", "@capacitor-community/admob": "^3.2.0", "@capacitor/android": "^3.3.3", "@capacitor/app": "^1.0.7", "@capacitor/camera": "^1.2.2", "@capacitor/core": "3.3.3", "@capacitor/device": "1.1.1", "@capacitor/filesystem": "^1.0.6", "@capacitor/haptics": "^1.1.3", "@capacitor/keyboard": "^1.2.0", "@capacitor/push-notifications": "^1.0.7", "@capacitor/share": "^1.0.4", "@capacitor/splash-screen": "^1.2.0", "@capacitor/status-bar": "^1.0.6", "@capacitor/storage": "^1.2.3", "@ionic/angular": "^6.0.1", "@ionic/pwa-elements": "^3.1.1", "cordova-plugin-androidx-adapter": "^1.1.3", "cordova-plugin-file": "^6.0.2", "cordova-plugin-googleplus": "^8.5.1", "cordova-plugin-telerik-imagepicker": "^2.3.6", "cordova-plugin-x-socialsharing": "^6.0.3", "cordova-promise-polyfill": "0.0.2", "core-js": "^3.20.0", "es6-promise-plugin": "^4.2.2", "firebase": "^9.4.0", "rxjs": "~6.6.0", "tslib": "^2.2.0", "zone.js": "~0.11.4" }

dksanket commented 2 years ago

Seems we have these in common: @dksanket

{ "@angular/animations": "^13.1.1", "@angular/common": "~13.1.1", "@angular/core": "~13.1.1", "@angular/fire": "^7.2.0", "@angular/forms": "~13.1.1", "@angular/platform-browser": "~13.1.1", "@angular/platform-browser-dynamic": "~13.1.1", "@angular/router": "~13.1.1", "@angular/service-worker": "~13.1.1", "@awesome-cordova-plugins/core": "^5.37.3", "@capacitor-community/admob": "^3.2.0", "@capacitor/android": "^3.3.3", "@capacitor/app": "^1.0.7", "@capacitor/camera": "^1.2.2", "@capacitor/core": "3.3.3", "@capacitor/device": "1.1.1", "@capacitor/filesystem": "^1.0.6", "@capacitor/haptics": "^1.1.3", "@capacitor/keyboard": "^1.2.0", "@capacitor/push-notifications": "^1.0.7", "@capacitor/share": "^1.0.4", "@capacitor/splash-screen": "^1.2.0", "@capacitor/status-bar": "^1.0.6", "@capacitor/storage": "^1.2.3", "@ionic/angular": "^6.0.1", "@ionic/pwa-elements": "^3.1.1", "cordova-plugin-androidx-adapter": "^1.1.3", "cordova-plugin-file": "^6.0.2", "cordova-plugin-googleplus": "^8.5.1", "cordova-plugin-telerik-imagepicker": "^2.3.6", "cordova-plugin-x-socialsharing": "^6.0.3", "cordova-promise-polyfill": "0.0.2", "core-js": "^3.20.0", "es6-promise-plugin": "^4.2.2", "firebase": "^9.4.0", "rxjs": "~6.6.0", "tslib": "^2.2.0", "zone.js": "~0.11.4" }

Hi @ghonche , Thank you so much for sharing your findings. But after so many trial and errors, I found out that "cordova-plugin-facebook4": "^6.4.0" was the culprit. After removing this package, I am able to pick the images in the first go. Please check if that helps you. Thank you again for your time.

jcesarmobile commented 2 years ago

closing as the reporter can't reproduce in a separate app and looks like some other plugins are interfering

ghonche commented 2 years ago

Hi @dksanket , yeah it worked!! for me the @awesome-cordova-plugins/facebook/ngx plugin was interfering. Thank you a lot for your help. Please tell me if you find our what is the problem with facebook plugins and if there is any alternatives.

dksanket commented 2 years ago

Hi @dksanket , yeah it worked!! for me the @awesome-cordova-plugins/facebook/ngx plugin was interfering. Thank you a lot for your help. Please tell me if you find our what is the problem with facebook plugins and if there is any alternatives.

Hi @ghonche , glad that it helped. I didn't investigate more after that, have removed that plugin as of now, will let you know if I find the cause, and meanwhile if you figure out any alternative, please do let me know.

ionitron-bot[bot] commented 1 year ago

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of the plugin, please create a new issue and ensure the template is fully filled out.