Repository: flutter
Issue: [video_player_avfoundation] Video FPS is SLOW from version 2.5.7+
Labels: platform-ios,c: performance,p: video_player,package,P2,team-ios,triaged-ios

### What package does this bug report belong to?

video_player

### What target platforms are you seeing this bug on?

iOS

### Have you already upgraded your packages?

Yes

### Dependency versions

<details><summary>pubspec.lock</summary>

```lock
https://pastebin.com/imgnpXGS
```

</details>


### Steps to reproduce

This issue occurs on iOS when the video_player_avfoundation dependency is set to version 2.5.7 or newer.

### Expected results

Videos FPS should run smoothly as they do when video_player_avfoundation is set to version 2.5.6 or lower.

### Actual results

Videos FPS are slow on iOS when the video_player_avfoundation is set to version 2.5.7 or newer.

### Code sample

<details open><summary>Code sample</summary>

```dart
import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: VideoPlayerScreen(),
    );
  }
}

class VideoPlayerScreen extends StatefulWidget {
  const VideoPlayerScreen({super.key});

  @override
  State<VideoPlayerScreen> createState() => _VideoPlayerScreenState();
}

class _VideoPlayerScreenState extends State<VideoPlayerScreen> {
  late VideoPlayerController _controller;

  @override
  void initState() {
    super.initState();
    _controller = VideoPlayerController.networkUrl(Uri.parse('https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4'));

    _controller.addListener(() {
      setState(() {});
    });
    _controller.setLooping(true);
    _controller.initialize();
    _controller.play();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: _controller.value.isInitialized
            ? AspectRatio(
                aspectRatio: _controller.value.aspectRatio,
                child: VideoPlayer(_controller),
              )
            : const CircularProgressIndicator(),
      ),
    );
  }

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }
}
```

</details>


### Screenshots or Videos

<details open>
<summary>Screenshots / Video demonstration</summary>

Before:
https://github.com/flutter/flutter/assets/48541395/9a317f27-de8a-4eb1-b0bf-a7370cc651e9

After:
https://github.com/flutter/flutter/assets/48541395/3e3c28d0-8eb6-4169-a733-bf6646888b7e

</details>

https://github.com/flutter/flutter/assets/48541395/9a317f27-de8a-4eb1-b0bf-a7370cc651e9

https://github.com/flutter/flutter/assets/48541395/3e3c28d0-8eb6-4169-a733-bf6646888b7e


### Logs

<details open><summary>Logs</summary>

```console
[Paste your logs here]
```

</details>


### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
[✓] Flutter (Channel stable, 3.22.2, on macOS 14.2.1 23C71 darwin-arm64, locale en-AU)
    • Flutter version 3.22.2 on channel stable at /Users/andrewmanettas/development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 761747bfc5 (3 weeks ago), 2024-06-05 22:15:13 +0200
    • Engine revision edd8546116
    • Dart version 3.4.3
    • DevTools version 2.34.3

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    • Android SDK at /Users/andrewmanettas/Library/Android/sdk
    • Platform android-33, build-tools 33.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15F31d
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)

[✓] VS Code (version 1.90.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.90.0

[✓] Connected device (4 available)
    • Andrew (mobile)                 • 00008101-000C29302122001E • ios            • iOS 17.5.1 21F90
    • macOS (desktop)                 • macos                     • darwin-arm64   • macOS 14.2.1 23C71 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad     • darwin         • macOS 14.2.1 23C71 darwin-arm64
    • Chrome (web)                    • chrome                    • web-javascript • Google Chrome 126.0.6478.116

[✓] Network resources
    • All expected network resources are available.

• No issues found!
```

</details>