Comments (13)
@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.
@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.
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.
I tested fetching roll with more than 2.5k photos on iPhone 6
from cordova-plugin-photos.
@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.
Could you please provide your snippet of code you use.
from cordova-plugin-photos.
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.
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 30
ms 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:
- Amount of all available photos is multiple of specified
limit
value - e.g.limit == 10
but all available photos is100
:100 % 10 == 0
(looks like it's not your case). - 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:
- Get all the collections;
- 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" collectionMode
s as well.
from cordova-plugin-photos.
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.
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.
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.
Do you still develop this plugin for Cordvoa? @domax
from cordova-plugin-photos.
What should I do to get the ID:s of the skipped assets?
Assets are skipped in 3 cases:
- if asset has no file name (line 190 in CDVPhotos.m)
- if name of asset doesn't match the regexp
^(.+)\.([a-z]{3,4})$
(line 196 in CDVPhotos.m) - 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)
- App is crashed on photos() call that returns huge amount of records
- Almost none of the images honour the dimension setting HOT 4
- image() return base64 or dataURI HOT 4
- Phonegap Build error with Android HOT 1
- Wrong orientation in Android HOT 2
- Get access to URI ? HOT 2
- Get native paths of my images HOT 1
- Ask for contributing HOT 3
- collections() return Error: Invalid column DISTINCT bucket_id only on Android 10 HOT 4
- Compilation error on Android HOT 7
- Impossible to get the image HOT 2
- Does not work with API 29
- Add getting image as file URL HOT 3
- Some assets don't return thumbnails on iOS
- Real size of thumbnails is lesser than requested on iOS
- Display ArrayBuffer in canvas looks scrambled HOT 3
- Some images are fetched in wrong orientation HOT 10
- Add timestamp in millis into Photos.photos() output
- Add optioning of fetching delay between photos() bundles
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cordova-plugin-photos.