Skip to content

Conversation

@raju-muliyashiya
Copy link
Contributor

fixes Issue #173092

Pre-Review Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] page, which explains my responsibilities.
  • I read and followed the [relevant style guides] and ran [the auto-formatter].
  • I signed the [CLA].
  • The title of the PR starts with the name of the package surrounded by square brackets, e.g. [shared_preferences]
  • I [linked to at least one issue that this PR fixes] in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the [pub versioning philosophy], or I have commented below to indicate which [version change exemption] this PR falls under[^1].
  • I updated CHANGELOG.md to add a description of the change, [following repository CHANGELOG style], or I have commented below to indicate which [CHANGELOG exemption] this PR falls under[^1].
  • I updated/added any relevant documentation (doc comments with ///).

Description

  • Fixes the deprecated tracksWithMediaType: API usage that causes compilation warnings on iOS 18/macOS 15.

Changes

  • Migrated to loadTracksWithMediaType:completionHandler: for iOS 15.0+/macOS 12.0+
  • Added backward compatibility for iOS 13.0-14.x and macOS 10.15-11.x using pragma directives

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request addresses the deprecation of tracksWithMediaType: by migrating to loadTracksWithMediaType:completionHandler: for newer iOS/macOS versions and providing backward compatibility for older OS versions. The changes correctly update the CHANGELOG.md and pubspec.yaml files. The core logic in FVPVideoPlayer.m effectively handles the API transition using @available checks and diagnostic pragmas. However, there are a couple of areas for improvement regarding type specificity and error handling in the Objective-C code.

* Resolve `tracksWithMediaType:` deprecations.
* Use `loadTracksWithMediaType:completionHandler:` for iOS 15.0+/macOS 12.0+.

* ## 2.8.8

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The line * ## 2.8.8 appears to be a formatting error. It introduces a nested heading with an asterisk. It should likely be ## 2.8.8 without the asterisk, or the new entries should be placed directly under the existing ## 2.8.8 heading.

Suggested change
* ## 2.8.8
## 2.8.8

// Do not use video composition when it is not needed.
if (CGAffineTransformIsIdentity(self->_preferredTransform)) {
return;
void (^processVideoTracks)(NSArray *) = ^(NSArray *tracks) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For better type safety and clarity, consider specifying the type of the tracks array in the processVideoTracks block. The loadTracksWithMediaType:completionHandler: already provides NSArray<AVAssetTrack *> *.

Suggested change
void (^processVideoTracks)(NSArray *) = ^(NSArray *tracks) {
void (^processVideoTracks)(NSArray<AVAssetTrack *> *) = ^(NSArray<AVAssetTrack *> *tracks) {

NSError *_Nullable error) {
if (error == nil && tracks != nil) {
processVideoTracks(tracks);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The completion handler for loadTracksWithMediaType:completionHandler: checks for error == nil, but if an error occurs, it is not handled or logged. It's good practice to at least log the error to aid in debugging, even if no further action is taken.

                       if (error == nil && tracks != nil) {
                         processVideoTracks(tracks);
                       } else if (error != nil) {
                         NSLog(@"Error loading tracks: %@", error);
                       }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

error: tracksWithMediaType: is deprecated: first deprecated in macOS 15.0 - Use loadTracksWithMediaType:completionHandler: instead

1 participant