terikon / cordova-plugin-photo-library

Maintainer needed. Please contact if you're using this library in your project
MIT License
149 stars 294 forks source link

Images not showing up #46

Open arberkryeziu opened 7 years ago

arberkryeziu commented 7 years ago
  1. Images returned from this plugin are not showing up. Also from the Ionic2 demo project.
    @viskin you said that the demo project is showing pictures on your iOS device. But I see that in index.html (in demo project) you did not include the CSP mentioned in Readme. I tried with CSP and without CSP (ink. pipe for sanitizing the url), but no luck whatsoever. I think the problem relies on this (ie. CSP) since the photos are showing up in the iPhone simulator, just not in real device. Is it necessary to change any settings in XCode btw ?

  2. @viskin You mentioned somewhere that you are using CropperJS in combination with this plugin, in some of your projects. I noticed that for big sized images (ca. 4MB), it takes about 3-5sec for the image to load. However, Im passing the base64 image into it (since I cant make it work with FILE_URI/ NATIVE_URI), so maybe thats the case. Can you help me with the approach you took, to optimize this step a little? I think If you could just pass the NATIVE_URI/FILE_URI into cropperJS, it would be significantly faster, since theres no need to convert it into base64.

I would appreciate some thoughts here ... Thank You in Advance

arberkryeziu commented 7 years ago

Some additional information:

Using the pipe for sanitization results in such object: {"changingThisBreaksApplicationSecurity":"cdvphotolibrary://photo?photoId=1DE19521-42C8-46DD-8DB8-B97381D99FF2%2FL0%2F001"}

arberkryeziu commented 7 years ago

So, finally I have some images showing up in my iPhone. It seems that the problem was, the plugin somehow does not/takes too long to, show images that are synchronized in the iCloud. The majority of my photos are synchronized in the iCloud.
So I changed this line and this line to 'true'. More photos are showing up, however not all of them. I did restrict to only show 50 images from the returned library array, otherwise, for all the photos in the library (ca. 5000), it takes infinitly long. What I also noticed is that, thumbnails are less problematic (i.e. I have more thumbnails showing up) than the full image. There are also cases, where the thumbnail is not there, but the full image of it is showing up.

So I think there is a problem with photos synched in iCloud.

Cordova CLI: 6.5.0 
Ionic Framework Version: 2.3.0
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 1.1.4
ios-deploy version: 1.9.1 
ios-sim version: 5.0.13 
OS: macOS Sierra
Node Version: v7.5.0
Xcode version: Xcode 8.2.1 Build version 8C1002
viskin commented 7 years ago

Thanks, I've set isNetworkAccessAllowed to false just because it's too slow. So if I get it right, we should display iCloud synced photos, but it should be fast. That's what Apple's Photos app does, right? So it should be possible.

arberkryeziu commented 7 years ago

So if I get it right, we should display iCloud synced photos, but it should be fast.

Yes, not only fast, the most important thing is to display ALL the photos. I believe the majority of iPhone/iPad owners sync their photos into iCloud, since in the newer iOS versions, the iCloud sync is automatically switched ON.

That's what Apple's Photos app does, right?

Not only Apple's Photos app does it. Ive seen lots of other apps, which have customized photo galleries. At least they display all the thumbnails, extremly fast. However, for the photos that are synced into the iCloud, they show a mark (e.g. like a little point in the thumbnail), but when you click on thumbnail, then the full photo gets loaded from the iCloud

So it would be great if the plugin returns a boolean to tell if the photo is in the iCloud or if its local. If it is in the iCloud and the user wants it, then the plugin should somehow trigger a download from iCloud.

Thanks

viskin commented 7 years ago

the most important thing is to display ALL the photo

I'd really wish to reproduce this on my phone. I have no idea why the library misses some photos on some devices.

they show a mark (e.g. like a little point in the thumbnail), but when you click on thumbnail, then the full photo gets loaded from the iCloud

Great idea! Do you remember in which app behaves like this? I'd like to see it in action and mimic it in the library. We can have 2 types of thumbnail url - the fast one that returns the "dot" for iCloud images, and the slow one that loads the actual thumbnail over the network.

arberkryeziu commented 7 years ago

I'd really wish to reproduce this on my phone

I think you can if all your photos are synced into iCloud. Because I have checked in my case; all local stored photos are displayed correctly by this plugin. All other synced photos, are problematic.

Do you remember in which app behaves like this?

Even the Apple's Photo app behaves like this. Usually synced photos have a cloud mark in bottom-right corner of thumbnail. When you click on it, the photo first has low quality, and then it is loaded from iCloud. But you can also check out this app

So I think, thumbnails can be fetched somehow from the iphone and no network should be needed for them. An idea: Load all thumbnails (without netwokr access). When you click on the thumbnail, call cordova.plugins.photoLibrary.getPhotoURL() which then fully loads that specific photo (with network access enabled). Hence there is no need to load all the photos beforehand (with network access enabled)

arberkryeziu commented 7 years ago

So. I can confirm now, the reason that thumbnails and/or photos not being displayed on iOS devices, is that they are synced to iCloud (and not stored locally), and the plugin does not handle that very well (i.e. does not trigger a download from the iCloud).

I had cases that some thumbnails were not being displayed. Yesterday, I realized that they were not displayed also in Apple's Photo app. On Apple's Photo app, as soon I scrolled over them, they were downloaded from iCloud. Then, they were displaying also in my app using the plugin.

@viskin I believe, all your photos are locally stored, thats why you see all the photos.

After changing thumbnailRequestOptions.isNetworkAccessAllowed = true and imageRequestOptions.isNetworkAccessAllowed = true , what should be all executed? I just rerun my app using ionic run ios -lc. However, these changes have no effect.

viskin commented 7 years ago

Sorry for the plugin causes too many problems on iOS. I just have no time to fix them anytime soon. And it will not be good to add kind-of advanced functionality of managing iCloud, without making access to local images reliable. Forking/contributing are welcome, but I should say that this plugin is currently not my primary focus. I will try to find a co-maintainer.