Giter VIP home page Giter VIP logo

Comments (13)

domax avatar domax commented on June 27, 2024

@firsname-markus : Did you use limit option for bundle-related fetching?
If you don't use it, then you'll have a problem with memory in your device. I strongly recommend to use limit for huge rolls.

from cordova-plugin-photos.

firsname-markus avatar firsname-markus commented on June 27, 2024

@domax : Yep, i tried with different combos like --> limit: 10 interval:100, limit: 30 interval: 100, limit: 100 interval: 1000... No matter what i always get 393 photos.

I'm testing with iPhone 7 and i havent noticed any freezing or slowing no matter what combo of settings, but still only 393 photos..

from cordova-plugin-photos.

domax avatar domax commented on June 27, 2024

That shouldn't happen then. The only reason that may prevent fetching is that your 394th photo has some absent, wrong or corrupted attribute. Are you able to run your app in Xcode and catch in debugger what happens with 394th photo in your roll?

from cordova-plugin-photos.

domax avatar domax commented on June 27, 2024

I tested fetching roll with more than 2.5k photos on iPhone 6

from cordova-plugin-photos.

firsname-markus avatar firsname-markus commented on June 27, 2024

@domax first of all, thanks for the support :)
Photo #393 seems to give me "Error in Success callbackId: Photos1574288256 : TypeError: undefined is not an object (evaluating 'photos[0].id') (console-via-logger.js, line 173)" and "TypeError: undefined is not an object (evaluating 'photos[0].id')"

Fecthing photo #393 for some reason returns an empty object..

EDIT: Actually #392 is the last working fetch, after that only empty object is returned. If i put offset to for example 410, still Photos are returning [] and fails on that. Weird because all the other apps in my phone shows all the photos just fine

from cordova-plugin-photos.

domax avatar domax commented on June 27, 2024

Could you please provide your snippet of code you use.

from cordova-plugin-photos.

firsname-markus avatar firsname-markus commented on June 27, 2024

I have a clean PhoneGap project with only this inside deviceReady..

        Photos.photos({ "limit": 10, "interval": 100 },
            function(photos) {
                console.log(JSON.stringify(photos));
            },
            function(error) {
                console.log(JSON.stringify(error));
            }
        );

as I said earlier i have tried with different limit ( 1-100), interval (30-3000) and offset (395++). I have also tried to determine the album. Each will fetch without freezing, slacking or other problems until photo #392. It doesn't matter which photo is #392. #393 always returns []. IF offset is for example 395 it returns []

I'm totally out of ideas

from cordova-plugin-photos.

domax avatar domax commented on June 27, 2024

OK, got it.

First of all - interval doesn't affect the content of fetching data - it's just a background thread's pause between bundles. A default of 30ms is enough as a rule.

Photos.photos() method returns you bundles. If you don't specify limit option, you'll get only one callback with a bundle. In case you specify limit option, you may get several callbacks, where each of them will have a bundle - even empty one.
That allows you to detect the fact that fetching process is finished (see example 2 for details). So, empty last bundle is a normal.

It's a second question - why it is empty. That may happen in following cases:

  1. Amount of all available photos is multiple of specified limit value - e.g. limit == 10 but all available photos is 100: 100 % 10 == 0 (looks like it's not your case).
  2. There are filtered out images from your last bundle: a native implementation of Photos.photos() method contains several very simple filters to get only "valid" images:
    • asset should be only PHAssetMediaTypeImage;
    • it's name must match to following case insensitive regular expression: ^(.+)\.([a-z]{3,4})$;
    • uppercased name extension must be one of: "JPG", "JPEG", "PNG", "GIF", "TIF" or "TIFF";

2nd I believe is your case.

So far you have no any errors during fetching, I suppose you have only 393 available photos in your roll. To make sure try to use the following snippet:

Photos.photos(console.log, console.error);

This will try to get all available photos on your "Camera Roll" "smart" album at once and drop it all into webview log. Please notice that calling photos() method w/o collections argument gets photos only from one specific collection/album - "Camera Roll".

You may try to:

  1. Get all the collections;
  2. Then request photos from all of these collections.

Smth like that:

Photos.collections({"collectionMode": "ALBUMS"},
    function(albums) {
        var ids = [];
        albums.forEach(function(album){ids.push(album.id)});
        console.log(ids);
        Photos.photos(ids, {limit:100}, console.log, console.error);
    }, console.error);

Since it's iOS, you may try "MOMENTS" and "SMART" collectionModes as well.

from cordova-plugin-photos.

firsname-markus avatar firsname-markus commented on June 27, 2024

Photos.photos(console.log, console.error);

--> returns 389 photos

Photos.collections({"collectionMode": "ALBUMS"},
    function(albums) {
        Photos.photos(albums, console.log, console.error);
    }, console.error);

--> returns 389 photos

Photos.collections({"collectionMode": "SMART"},
    function(albums) {
        Photos.photos(albums, console.log, console.error);
    }, console.error);

--> returns 389 photos

Photos.collections({"collectionMode": "MOMENTS"},
    function(albums) {
        Photos.photos(albums, console.log, console.error);
    }, console.error);

--> returns 389 photos

I have 569 photos in roll, all of them are either JPG, GIF or PNG

from cordova-plugin-photos.

domax avatar domax commented on June 27, 2024

Well, looks like I found where bug was - see comment for commit above.
@firsname-markus please check it (npm package 1.0.8 is published as well).
Just in case, I added code that gathers all skipped photos (iOS only) - they're logged with prefix skipped asset in Xcode output - I'll remove this code in future releases.

from cordova-plugin-photos.

orgotech-robin avatar orgotech-robin commented on June 27, 2024

Hey, I also got this issue.

I got 3,3k images but can only find 2,8k of them. My xCode output is filled with the skipped assets. Where I can see the ID of the images but I can't seem to find them in my js response.

Image counter:

Photos.photos({ "limit": 10, "interval": 100 },
        function(photos) {
            imgCounter = imgCounter + 10;
            console.log(imgCounter);
        },
        function(error) {
            console.log(error);
        }
    );

What should I do to get the ID:s of the skipped assets?

from cordova-plugin-photos.

orgotech-robin avatar orgotech-robin commented on June 27, 2024

Do you still develop this plugin for Cordvoa? @domax

from cordova-plugin-photos.

domax avatar domax commented on June 27, 2024

@orgotech-robin

What should I do to get the ID:s of the skipped assets?

Assets are skipped in 3 cases:

  1. if asset has no file name (line 190 in CDVPhotos.m)
  2. if name of asset doesn't match the regexp ^(.+)\.([a-z]{3,4})$ (line 196 in CDVPhotos.m)
  3. if file extension (2nd regexp group) isn't one of supported: jpg, jpeg, png, gif, tif, tiff (line 200 in CDVPhotos.m)

All these cases depend on (NSString*) getFilenameForAsset:(PHAsset*)asset method that extracts the filename - that's the most critical place here. I tried to use different ways to retrieve asset filename. The most correct way is to use requestContentEditingInputWithOptions method of asset, but it's asynchronous, that complicates everything alot (see commented lines 394-399 in CDVPhotos.m). So now is kinda hack is used - undocumented attribute "filename" of asset - maybe that's the root cause of asset skipping.

Do you still develop this plugin for Cordvoa?

Now I have neither time nor motivation for that. Feel free to take support of this plugin.

from cordova-plugin-photos.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.