)]}'
{
  "commit": "04de46e0b9364a6908c0fcf8c142d61e1cae019b",
  "tree": "0b7b278d7b75557420b8910b182da5445f1608e1",
  "parents": [
    "bbb0e516fb515ac047aceb240d636fa473d46560"
  ],
  "author": {
    "name": "misos1",
    "email": "30872003+misos1@users.noreply.github.com",
    "time": "Thu Apr 17 19:26:14 2025 +0200"
  },
  "committer": {
    "name": "GitHub",
    "email": "noreply@github.com",
    "time": "Thu Apr 17 17:26:14 2025 +0000"
  },
  "message": "[video_player_avfoundation] enable more than 30 fps (#7466)\n\nIn the player there was hardcoded 30 fps when setting up video composition. Now it uses timing from source track and also fallback `minFrameDuration` as seems `frameDuration` must be always set to something and it takes over in some situations as is mentioned in documentation about `sourceTrackIDForFrameTiming`. Also video composition setup is skipped when it is not needed when `preferredTransform` is identity.\r\n\r\nFunction `updatePlayingState` is called often right after `setupEventSinkIfReadyToPlay` but seems it was forgotten in `onListenWithArguments` and also it cannot be called in that way because `setupEventSinkIfReadyToPlay` may finish asynchronously when called again from line `[self performSelector:_cmd onThread:NSThread.mainThread withObject:self waitUntilDone:NO]` so now is `updatePlayingState` called right after `_isInitialized \u003d YES` which is what it needs to even do something.\r\n\r\nThere was one more obstacle for playing 60 fps videos on 60 hz screen. Seems there are at least two \"display links\" at play when playing video, one calls function `displayLinkFired` and other one from flutter engine calls `copyPixelBuffer` but only when `textureFrameAvailable` was called previously. But the order in which those two are called is undefined so 16 ms after `displayLinkFired` may be called `copyPixelBuffer` and right after that `displayLinkFired` and so on. But `copyPixelBuffer` steals the newest pixel buffer from video player output and in `displayLinkFired` `hasNewPixelBufferForItemTime` will not report another pixel buffer for time close to that. Then the next frame is not called `copyPixelBuffer` because `textureFrameAvailable` was not called and in this way it skips every second frame so it plays video at 30 fps. There was also a synchronization problem with `lastKnownAvailableTime`. Now pixel buffers are produced and reported just on a single place in `displayLinkFired` and received with correct synchronization in `copyPixelBuffer`. Ideally there would be just a single \"display link\" from flutter engine if it supported also pulling frames instead of only pushing (which is good enough for a camera where the system is pushing frames to us, but from player video output is needed to pull frames). Calling `textureFrameAvailable` every frame could accomplish that but it looks like this line in flutter engine is calling even when `copyPixelBuffer` returns NULL and it may be expensive (although there is no need to call it in such case):\r\n\r\n```\r\nsk_sp\u003cflutter::DlImage\u003e image \u003d [self wrapExternalPixelBuffer:_lastPixelBuffer context:context];\r\n```\r\n\r\nSeems there is some bug with the video player using this flutter engine on macos. Looks like the video is playing normally but then it starts \"tearing\", it looks like it is displaying frames normally but once in a while it shows some frame from the past like some previously cached frame. This is happening on the main branch but rendering on 60 fps exaggerates it (it is not caused by this PR).",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "81e43153e7a7dc9d24c3ea420c2aefb1eac3e85e",
      "old_mode": 33188,
      "old_path": "packages/video_player/video_player_avfoundation/CHANGELOG.md",
      "new_id": "992c015df1ba4404d5347ee7d028ee1ae01e022c",
      "new_mode": 33188,
      "new_path": "packages/video_player/video_player_avfoundation/CHANGELOG.md"
    },
    {
      "type": "modify",
      "old_id": "e3c1d058728e2248e65263281e3920cf2ed9e7f5",
      "old_mode": 33188,
      "old_path": "packages/video_player/video_player_avfoundation/darwin/RunnerTests/VideoPlayerTests.m",
      "new_id": "4bb06d7d97048a53307a31ec4e7a5e992590c7a2",
      "new_mode": 33188,
      "new_path": "packages/video_player/video_player_avfoundation/darwin/RunnerTests/VideoPlayerTests.m"
    },
    {
      "type": "modify",
      "old_id": "e73d486da17ef6bb7634b012012970f317ffc732",
      "old_mode": 33188,
      "old_path": "packages/video_player/video_player_avfoundation/darwin/video_player_avfoundation/Sources/video_player_avfoundation/FVPFrameUpdater.m",
      "new_id": "0c66f6f639b03aa3124a0c6adf6813dfced99c48",
      "new_mode": 33188,
      "new_path": "packages/video_player/video_player_avfoundation/darwin/video_player_avfoundation/Sources/video_player_avfoundation/FVPFrameUpdater.m"
    },
    {
      "type": "modify",
      "old_id": "509d0b5e55a50b5fcc7c3eb089b7faa83da07fbf",
      "old_mode": 33188,
      "old_path": "packages/video_player/video_player_avfoundation/darwin/video_player_avfoundation/Sources/video_player_avfoundation/FVPTextureBasedVideoPlayer.m",
      "new_id": "68f8a4673c65692935c82a8249f46d36aaff70c4",
      "new_mode": 33188,
      "new_path": "packages/video_player/video_player_avfoundation/darwin/video_player_avfoundation/Sources/video_player_avfoundation/FVPTextureBasedVideoPlayer.m"
    },
    {
      "type": "modify",
      "old_id": "d1d096e7b287b610235aa16ed049ce73de56bc4b",
      "old_mode": 33188,
      "old_path": "packages/video_player/video_player_avfoundation/darwin/video_player_avfoundation/Sources/video_player_avfoundation/FVPVideoPlayer.m",
      "new_id": "04d6d21cb2e4db2b883263d6b86a0225dced349f",
      "new_mode": 33188,
      "new_path": "packages/video_player/video_player_avfoundation/darwin/video_player_avfoundation/Sources/video_player_avfoundation/FVPVideoPlayer.m"
    },
    {
      "type": "modify",
      "old_id": "80d400629b258aecdfcfbff6c4acc3afc38977a1",
      "old_mode": 33188,
      "old_path": "packages/video_player/video_player_avfoundation/darwin/video_player_avfoundation/Sources/video_player_avfoundation/include/video_player_avfoundation/FVPDisplayLink.h",
      "new_id": "54e338993c4d521f7cb1e33720f40e394ea5a08d",
      "new_mode": 33188,
      "new_path": "packages/video_player/video_player_avfoundation/darwin/video_player_avfoundation/Sources/video_player_avfoundation/include/video_player_avfoundation/FVPDisplayLink.h"
    },
    {
      "type": "modify",
      "old_id": "9d5466d8757b1b366f7432b6012360581603968e",
      "old_mode": 33188,
      "old_path": "packages/video_player/video_player_avfoundation/darwin/video_player_avfoundation/Sources/video_player_avfoundation/include/video_player_avfoundation/FVPFrameUpdater.h",
      "new_id": "274b666f2873852928e3883f3230f98c9b7b96ea",
      "new_mode": 33188,
      "new_path": "packages/video_player/video_player_avfoundation/darwin/video_player_avfoundation/Sources/video_player_avfoundation/include/video_player_avfoundation/FVPFrameUpdater.h"
    },
    {
      "type": "modify",
      "old_id": "9bdb321ae16469510062004c6582e220daf406ea",
      "old_mode": 33188,
      "old_path": "packages/video_player/video_player_avfoundation/darwin/video_player_avfoundation/Sources/video_player_avfoundation_ios/FVPDisplayLink.m",
      "new_id": "5ea6ea0135dabf95efef9215eb6bb359b2b4ea31",
      "new_mode": 33188,
      "new_path": "packages/video_player/video_player_avfoundation/darwin/video_player_avfoundation/Sources/video_player_avfoundation_ios/FVPDisplayLink.m"
    },
    {
      "type": "modify",
      "old_id": "cd5670fa5a37bc408b8b698ce39b2270575dc652",
      "old_mode": 33188,
      "old_path": "packages/video_player/video_player_avfoundation/darwin/video_player_avfoundation/Sources/video_player_avfoundation_macos/FVPDisplayLink.m",
      "new_id": "cb9682e6011a912b9c820eaf773ac435f97c8662",
      "new_mode": 33188,
      "new_path": "packages/video_player/video_player_avfoundation/darwin/video_player_avfoundation/Sources/video_player_avfoundation_macos/FVPDisplayLink.m"
    },
    {
      "type": "modify",
      "old_id": "3db089c7ccf2820836aea433d8bec51caf59b78f",
      "old_mode": 33188,
      "old_path": "packages/video_player/video_player_avfoundation/pubspec.yaml",
      "new_id": "20087db42cc6f013818f92747fc64ecbb2498306",
      "new_mode": 33188,
      "new_path": "packages/video_player/video_player_avfoundation/pubspec.yaml"
    }
  ]
}
