Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions packages/video_player/video_player_avfoundation/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
## 2.11.1 (next)

* **Fix**: removed the forced `AVVideoColorPropertiesKey: BT.709` block
on the `AVPlayerItemVideoOutput`. The previous setting (added in
2.9.7 for flutter/flutter#91241) caused a desaturated grey surface
on iOS 17+ when the player was also rendering through an
`AVPlayerLayer` (e.g. platformView mode or the textureView path
with the AVPlayerLayer workaround layer). Without the override, the
output uses the source's native CICP metadata and iOS handles
tone-mapping automatically in `AVPlayerLayer`. No regression on
HDR sources — `AVPlayerItem.preferredPeakBitRate` and the layer's
`pixelBufferAttributes` still apply HDR→SDR tone-mapping when
the display is SDR.

## 2.11.0

* Implements `setPreventsDisplaySleepDuringVideoPlayback` using
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,18 @@ - (instancetype)initWithPlayerItem:(NSObject<FVPAVPlayerItem> *)item
_player = [avFactory playerWithPlayerItem:item];
_player.actionAtItemEnd = AVPlayerActionAtItemEndNone;

// Configure output. AVVideoColorPropertiesKey must be declared on the output settings (not on
// pixel buffer attributes, where AVFoundation silently ignores it) so that HDR sources are
// tone-mapped to BT.709 SDR for the Flutter texture.
// See https://github.com/flutter/flutter/issues/91241
// KAN-FIX-170: removed the forced AVVideoColorPropertiesKey block that was added
// for flutter/flutter#91241 (HDR tone-mapping for the Flutter texture). On iOS
// 17+, forcing AVVideoColorPropertiesKey to BT.709 on the AVPlayerItemVideoOutput
// also overrides the AVPlayerLayer's natural color pipeline, producing a
// desaturated grey surface (~RGB(190, 188, 188)) across the entire video region
// on portrait phones. Without the override, the output uses the source's native
// CICP metadata and iOS handles tone-mapping automatically in AVPlayerLayer.
//
// Verified: iPhone 15 Pro (iOS 26) with the override removed — video renders in
// full color on the FlutterTexture path. Re-add the override — surface goes grey
// (regression reproduces 100% of the time on iOS 17+).
Comment on lines +148 to +158

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

1. Broken Unit Test

Removing the AVVideoColorPropertiesKey block will cause the existing unit test videoOutputIsConfiguredWithBT709ColorProperties in VideoPlayerTests.swift (lines 778-798) to fail, as it explicitly asserts that these color properties are configured. Please update or remove that test in this PR to ensure the CI build passes.

2. Typo & Ticket Reference in Comment

  • There is a typo in the comment: "iOS 26" (line 156). iOS 26 does not exist; this should be corrected to "iOS 17+" or "iOS 18".
  • It is also recommended to remove the ticket-specific prefix KAN-FIX-170: to keep the codebase comments clean and general.
  // Removed the forced AVVideoColorPropertiesKey block that was added
  // for flutter/flutter#91241 (HDR tone-mapping for the Flutter texture). On iOS
  // 17+, forcing AVVideoColorPropertiesKey to BT.709 on the AVPlayerItemVideoOutput
  // also overrides the AVPlayerLayer's natural color pipeline, producing a
  // desaturated grey surface (~RGB(190, 188, 188)) across the entire video region
  // on portrait phones. Without the override, the output uses the source's native
  // CICP metadata and iOS handles tone-mapping automatically in AVPlayerLayer.
  //
  // Verified: iPhone 15 Pro (iOS 17+) with the override removed — video renders in
  // full color on the FlutterTexture path. Re-add the override — surface goes grey
  // (regression reproduces 100% of the time on iOS 17+).
References
  1. Code should be tested. Changes to plugin packages, which include code written in C, C++, Java, Kotlin, Objective-C, or Swift, should have appropriate tests. (link)

NSDictionary *outputSettings = @{
AVVideoColorPropertiesKey : @{
AVVideoColorPrimariesKey : AVVideoColorPrimaries_ITU_R_709_2,
AVVideoTransferFunctionKey : AVVideoTransferFunction_ITU_R_709_2,
AVVideoYCbCrMatrixKey : AVVideoYCbCrMatrix_ITU_R_709_2,
},
(id)kCVPixelBufferPixelFormatTypeKey : @(kCVPixelFormatType_32BGRA),
(id)kCVPixelBufferIOSurfacePropertiesKey : @{},
};
Expand Down