Closed lyio closed 3 years ago
https://stackoverflow.com/a/36732766/2419001 Seems to suggest that [PHAsset fetchKeyAssetsInAssetCollection:collection options:option]
complains when it is passed something than a PHAsset
.
But PHAssetCollection
could either be a PHAsset
or a PHCollectionList
. This would mean that line 104 needs to be wrapped in a check if the collection is a PHAsset
before trying to call fetchKeyAssetsInAssetCollection
with it.
if ([collection isKindOfClass:[PHAssetCollection class]]) {
PHFetchResult<PHAsset *> *result = [PHAsset fetchKeyAssetsInAssetCollection:collection options:option];
}
Edit:
After looking up what a PHCollectionList
is, I found this https://developer.apple.com/documentation/photokit/phcollectionlist.
A group containing Photos asset collections, such as Moments, Years, or folders of user-created albums.
So I went and created a couple of folders on my test device and put some albums in it. And now I can trigger the exception reliably every time.
I will add this information to the description above.
Faced the same issue with the same description. Waiting for the merge of the open PR, as it will fix the problem. @CaiJingLong @lyio Thanks!
@CaiJingLong since you merged the PR for this, I guess I can close the issue, right?
Describe the bug
I am not sure what exactly is causing the problem, because I only have a stacktrace and no actual application state or steps that led to the exception.
But
[PHAsset fetchKeyAssetsInAssetCollection:collection options:option]
in line 104 in thePMManager.m
is throwing anNSInvalidArgumentException
when called with a specificPHFetchResult
.To Reproduce Again, I do not know how to trigger this exception because I only have an automated bug report.
[Edit] The problem occurs when the user tries to list assets from folders of user-defined albums. See https://developer.apple.com/documentation/photokit/phcollectionlist for a description.
Expected behavior I expect to not get an exception.
Flutter version 1.22.3
Smartphone (please complete the following information):
Log
This is the stacktrace for the exception.