sarriaroman / photoviewer

PhotoViewer Cordova Plugin
MIT License
157 stars 216 forks source link

Exception 'NSInvalidArgumentException', reason: '-[NSNull length]: unrecognized selector sent to instance #161

Open tobiasmuecksch opened 5 years ago

tobiasmuecksch commented 5 years ago

Hello,

I'm trying to open an image, that is located under an https:// URL.

XCode Error Screenshot:

Screenshot

Ionic Code:

const fullImageURL = 'https://burningparrot.com/assets/logo_v3.png';
console.log('OPENING FILE', fullImageURL);

if (this.platform.is('cordova')) {
    const options = {
        share: true, // default is false
        closeButton: true, // default is true
        copyToReference: true // default is false
    };
    this.photoViewer.show(fullImageURL, '', options);
}

Dependency versions:

"@ionic-native/photo-viewer": "^4.20.0"
"com-sarriaroman-photoviewer": "^1.2.1"
"cordova-ios": "5.0.0"
"ionic-angular": "3.9.2"

Am I doing something wrong? How can I fix this error?

tobiasmuecksch commented 5 years ago

I do have the same error with Ionic v4:

"@ionic/angular": "^4.0.0",
"@ionic-native/photo-viewer": "^5.2.0",
"com-sarriaroman-photoviewer": "1.2.1",
"cordova-ios": "5.0.0",

I have also tried:

"com-sarriaroman-photoviewer": "1.1.18",
tobiasmuecksch commented 5 years ago
"cordova-ios": "4.5.5",

Same issue

tobiasmuecksch commented 5 years ago

Similar error on Android (cordova-android@8.0.0):

Unable to start activity ComponentInfo{com.burningparrot.eeapp/com.sarriaroman.PhotoViewer.PhotoActivity}: 
java.lang.NullPointerException:
Attempt to invoke virtual method 'boolean org.json.JSONObject.has(java.lang.String)'
on a null object reference

I have also tried to avoid the ionic-native wrapper:

const options = {
    share: true, // default is false
    closeButton: true, // default is true
    copyToReference: true // default is false
};

window['PhotoViewer'].show('https://burningparrot.com/assets/logo_v3.png', 'Optional Title', options);

The error stay's the same. I guess there's a problem with the communication between the renderer process and the plugin.

asa47 commented 5 years ago

Hello @tobiasmuecksch, I have looked at the code, and it looks like all the parameters in the 'options' variable are required. If you don't add them, it will trigger an exception.

const options = {
    share: true, // default is false
    closeButton: true, // default is true
    copyToReference: true, // default is false
        headers: "",  // If it is not provided, it will trigger an exception
        piccasoOptions: { } // If it is not provided, it will trigger an exception
};

Please see the following: https://github.com/sarriaroman/photoviewer/blob/3fe843a9000fa19215530b44c214456acff415b4/www/PhotoViewer.js#L24

tobiasmuecksch commented 5 years ago

@asa47 That indeed fixed the issue. Thank you so much. I'll create a PR to fix the readme. Until then I'll leave this issue open.

halindrome commented 5 years ago

FWIW this is a breaking change. Patching the documentation is great, but everyone who uses this plugin is suddenly and unexpectedly going to have their app crash. Really should patch the underlying code to not require all the parameters.

mirko77 commented 5 years ago

@halindrome I agree. I had my app crashing and I was wondering why, here I am.

ejerskov commented 5 years ago

@asa47 Thanks alot

aacassandra commented 3 years ago

Hey, it's 2021 now, and the problem still persists. but can still be overcome with complete parameter options. btw thankyou @asa47

mirko77 commented 3 years ago

@aacassandra it's 2021, time to switch to Flutter

aacassandra commented 3 years ago

@mirko77 , Yes, you are right 🎉 . but since Vuejs released version 3, Ionic released a stable version of support for @ ionic/vue. We know that vue is a mix between angularjs and reactjs, which the developers are starting to be interested in. And plus the release of the native runtime Capasitor v2, which previously used Cordova. Also as the years have gone on, the devices have become more sophisticated. Whenever I build a plugin or other tool, it's still useful to speed up other projects (frontend, backend, react native, vue native & other nodejs), unlike the standalone flutter with Dart. I bet more on ionic development.

mirko77 commented 3 years ago

@mirko77 , Yes, you are right 🎉 . but since Vuejs released version 3, Ionic released a stable version of support for @ ionic/vue. We know that vue is a mix between angularjs and reactjs, which the developers are starting to be interested in. And plus the release of the native runtime Capasitor v2, which previously used Cordova. Also as the years have gone on, the devices have become more sophisticated. Whenever I build a plugin or other tool, it's still useful to speed up other projects (frontend, backend, react native, vue native & other nodejs), unlike the standalone flutter with Dart. I bet more on ionic development.

We looked at Capacitor but it is plagued by the same issues Cordova has: it still runs in the WebView and calls the hardware (like the camera) using Intents . Capacitor uses the same approach Cordova uses, and that crashes randomly on some devices... the issue has been going on for years and there is not any solution with the hybrid approach. This is just an example, we have other issues with our app (Ionic + Cordova), we thought about refactoring to react-native but it looks like Flutter is the next big thing by looking at the companies investing in it (Microsoft, Google, Toyota to name a few). Anyway if an app does not use the camera or background services or the local SQLite database, Ionic + Capacitor is a solid choice.

Another example would be the date picker broken by the iOS 14 update... That means we have to do a major update to our app just to fix a date picker... our team is fed up with fixing these things.

aacassandra commented 3 years ago

@mirko77 , Yes, you are right 🎉 . but since Vuejs released version 3, Ionic released a stable version of support for @ ionic/vue. We know that vue is a mix between angularjs and reactjs, which the developers are starting to be interested in. And plus the release of the native runtime Capasitor v2, which previously used Cordova. Also as the years have gone on, the devices have become more sophisticated. Whenever I build a plugin or other tool, it's still useful to speed up other projects (frontend, backend, react native, vue native & other nodejs), unlike the standalone flutter with Dart. I bet more on ionic development.

We looked at Capacitor but it is plagued by the same issues Cordova has: it still runs in the WebView and calls the hardware (like the camera) using Intents . Capacitor uses the same approach Cordova uses, and that crashes randomly on some devices... the issue has been going on for years and there is not any solution with the hybrid approach. This is just an example, we have other issues with our app (Ionic + Cordova), we thought about refactoring to react-native but it looks like Flutter is the next big thing by looking at the companies investing in it (Microsoft, Google, Toyota to name a few). Anyway if an app does not use the camera or background services or the local SQLite database, Ionic + Capacitor is a solid choice.

Another example would be the date picker broken by the iOS 14 update... That means we have to do a major update to our app just to fix a date picker... our team is fed up with fixing these things.

I hope you have a good day, but so far I have no problem with Ionic. I have worked for clients, such as integration with the camera plugin, sqlite, background service use fourground service. the date picker also works perfectly for me both on android and on ios or ios 14 tested work 100%. I only use ion-datetime and momentjs components. My friend is a flutter developer, we also often compare the performance between flutter and ionic, and it's not that much different. I think performance is determined by the coding style of each developer

mirko77 commented 3 years ago

@mirko77 , Yes, you are right 🎉 . but since Vuejs released version 3, Ionic released a stable version of support for @ ionic/vue. We know that vue is a mix between angularjs and reactjs, which the developers are starting to be interested in. And plus the release of the native runtime Capasitor v2, which previously used Cordova. Also as the years have gone on, the devices have become more sophisticated. Whenever I build a plugin or other tool, it's still useful to speed up other projects (frontend, backend, react native, vue native & other nodejs), unlike the standalone flutter with Dart. I bet more on ionic development.

We looked at Capacitor but it is plagued by the same issues Cordova has: it still runs in the WebView and calls the hardware (like the camera) using Intents . Capacitor uses the same approach Cordova uses, and that crashes randomly on some devices... the issue has been going on for years and there is not any solution with the hybrid approach. This is just an example, we have other issues with our app (Ionic + Cordova), we thought about refactoring to react-native but it looks like Flutter is the next big thing by looking at the companies investing in it (Microsoft, Google, Toyota to name a few). Anyway if an app does not use the camera or background services or the local SQLite database, Ionic + Capacitor is a solid choice. Another example would be the date picker broken by the iOS 14 update... That means we have to do a major update to our app just to fix a date picker... our team is fed up with fixing these things.

I hope you have a good day, but so far I have no problem with Ionic. I have worked for clients, such as integration with the camera plugin, sqlite, background service use fourground service. the date picker also works perfectly for me both on android and on ios or ios 14 tested work 100%. I only use ion-datetime and momentjs components. My friend is a flutter developer, we also often compare the performance between flutter and ionic, and it's not that much different. I think performance is determined by the coding style of each developer

I posted the issues, you might have a read at those. Happy you do not have any of those issues. We do, and our users are not happy.

aacassandra commented 3 years ago

Screen Shot 2021-03-24 at 00 46 56