Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 6, 2025

On iOS/macOS, using RequestType.video without an explicit filterOption returns all media types instead of just videos. Regression from #1313 which made filterOptionGroup nullable.

When filterOption is nil, [nil getFetchOptions:type] returns nil in Objective-C, resulting in no predicate on PHFetchOptions.

Changes

  • PMManager.m: getAssetOptions:filterOption: — Create basic PHFetchOptions with media type predicate when filterOption is nil
  • PMManager.m: getAssetCountWithType:option: — Route through getAssetOptions:filterOption: instead of calling getFetchOptions: directly
  • PMManager.m: getAssetsWithType:option:start:end: — Same fix, plus nil-safe needTitle access
Original prompt

This section details on the original issue you should resolve

<issue_title>[BUG] iOS - Asset picker with RequestType.video incorrectly shows images in addition to videos</issue_title>
<issue_description>Describe the bug
When using AssetPicker.pickAssets with requestType: RequestType.video on iOS, the picker still returns both images and videos, instead of only videos. Android behaves correctly.

How to reproduce
Steps to reproduce the behavior:

  1. Use the following code in a Flutter app:
final List<AssetEntity>? assets = await AssetPicker.pickAssets(
  context,
  pickerConfig: AssetPickerConfig(
    maxAssets: 1,
    requestType: RequestType.video,
  ),
);
  1. Run the app on an iOS device (iPhone 13, iOS 18.3).
  2. Open the asset picker and select assets.
  3. Observe that both images and videos are shown in the picker.

Expected behavior
The asset picker should display only video assets, consistent with requestType: RequestType.video.

Version information

  • Device: iPhone 13
  • OS: iOS 18.3
  • Package Version: wechat_assets_picker 9.8.0
  • Flutter Version: 3.35.4

Additional context

  • The issue only occurs on iOS. Android correctly filters only video assets.
  • The images currently displayed on iOS are not Live Photos, but regular static images. This indicates that the picker fails to correctly identify and filter out non-video media types.

Image
</issue_description>

<agent_instructions>The request type was sent through the method channel, yet it looks like the nullable filterOptionGroup causes some predicate conditions to be ignored unexpectedly in Darwin's implementation. This might have been first introduced by #1313.</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@AlexV525 Is this reproducible with the newly-cloned example? @fluttercandies-dev **AI Summary:** The iOS asset picker incorrectly displays images when `requestType` is set to `video`. This issue only occurs on iOS, not Android.

Custom agent used: PR Agent
An Agent that helps to implement features and fixes based on issues.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Fix asset picker to only show videos on iOS Fix iOS/macOS ignoring RequestType when filterOption is nil Dec 6, 2025
Copilot AI requested a review from AlexV525 December 6, 2025 04:41
@github-actions
Copy link

github-actions bot commented Dec 6, 2025

Download apk from here for a22a340

@AlexV525 AlexV525 marked this pull request as ready for review December 6, 2025 05:27
@AlexV525 AlexV525 requested a review from CaiJingLong as a code owner December 6, 2025 05:27
@AlexV525 AlexV525 merged commit f43fed1 into main Dec 6, 2025
13 checks passed
@AlexV525 AlexV525 deleted the copilot/fix-asset-picker-video-bug branch December 6, 2025 05:37
AlexV525 added a commit that referenced this pull request Dec 6, 2025
Same regression as iOS (fixed in #1354). When `filterOption` is null,
`option?.makeWhere()` returns null, resulting in no media type
predicate—queries return all media types regardless of `requestType`.

### Changes

- **IDBUtils.kt** — `getAssetCount` (both overloads),
`getAssetsByRange`: fall back to `RequestTypeUtils.toWhere(requestType)`
when option is null
- **DBUtils.kt** — `getAssetPathList`, `getMainAssetPathEntity`,
`getAssetPathEntityFromId`, `getAssetListPaged`, `getAssetListRange`:
same fix
- **AndroidQDBUtils.kt** — same methods, Android Q+ path

### Pattern

```kotlin
// Before: no filtering when option is null
val where = option?.makeWhere(requestType, args, false)

// After: apply type filter as fallback
val where = option?.makeWhere(requestType, args, false)
    ?: RequestTypeUtils.toWhere(requestType)
```

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: AlexV525 <[email protected]>
Co-authored-by: Alex Li <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] iOS - Asset picker with RequestType.video incorrectly shows images in addition to videos

2 participants