Open vtt2021 opened 3 years ago
have you found the solution?
Still having this issue
I think I'm also having this problem. Thumbnails turn into white squares after a split second.
After some investigations I found out that images are getting disappeared because these are backed in iCloud. To make it working, a special flag should be used for requestImageForAsset
method:
https://stackoverflow.com/questions/31037859/phimagemanager-requestimageforasset-returns-nil-sometimes-for-icloud-photos
So in QBAssetsViewController.m [line 474] I've defined options for the request that have networkAccessAllowed
set to YES. This fixed the issue, but presented another. Images in the list started "dancing" - appearing and disappearing in different cells, missplacing and sometimes duplicating. But after some time, the list becomes completely correct. If I use "synchronous" as YES in options, then the behavior is completely fine, but another issue is presented: UI freezes for seconds while images are loading. So it is not a solution, but it clearly shows that the issue is that after an image is retrieved, the UI rebuilds and order is broken. So I started playing with sorting options but still no luck.
So I decided to move another direction from start. Since all images are shown for a moment and then get lost, I've decided to try to prevent it from getting disappeared. I've found that updateCachedAssets
method is doing the thing. And well, good news, simple commenting it out makes it working!
Here is the fix (QBAssetsViewController.m):
Since the issue only reproduces in limited mode, it is reasonable to scope the fix to limited mode only. So add this piece of code into the start (line 21):
static bool isLimitedPermission() {
if (@available(iOS 14, *)) {
PHAuthorizationStatus accessLevel = [PHPhotoLibrary authorizationStatusForAccessLevel: PHAccessLevelReadWrite];
return accessLevel == PHAuthorizationStatusLimited;
}
return false;
}
Disable updateCachedAssets in limited mode (line 315):
if (isLimitedPermission()) { return; }
PS. One minor issue I found having this fix enabled is that when you are on items list page and then drag and drop the page ( using left side of the page) leads to items flicker for a moment. This could be fixed by commenting out all invokations of [self.collectionView reloadData];
PPS. I'm not an ios native developer and this is my first try, so I can't promise this is a good fix. Anybody with relevant experience is welcome to this thread!
Here is final file (remove .txt extension yourself): QBAssetsViewController.m.txt
Version
Tell us which versions you are using:
Platform
Tell us to which platform this issue is related
Expected behaviour
all thumbnails remain visible all the time
Actual behaviour
thumbnail images in picker grid get invisible one after another
Steps to reproduce
Note: if during first load user selects "All" as access mode, then everything works fine, until it is not switched to "Limited" in settings. then the issue is there and switching back to "All" doesn't help.
Note 2: iCloud storage is enabled with option "Optimize iPhone Storage" in Settings / Photos
Attachments
// stacktrace or any other useful debug info
Love react-native-image-crop-picker? Please consider supporting our collective: 👉 https://opencollective.com/react-native-image-crop-picker/donate