Skip to content

[macos] [metal] Memory leak when using external texture #79648

@cbenhagen

Description

@cbenhagen

It looks like there is a huge memory leak when using external texture on macOS. The memory usage of the video_player plugin grows quickly to multiple GB. Could also be that I made some mistake of course.

I am still trying to create a more minimalistic reproduction but until then the example of the macOS port of the video_player plugin can be used to reproduce the issue:
https://github.com/cbenhagen/plugins/tree/video_player_macos_new/packages/video_player/video_player_macos/example

The relevant code returning the buffer is a copy of the iOS implementation:

- (CVPixelBufferRef)copyPixelBuffer {
  CMTime outputItemTime = [_videoOutput itemTimeForHostTime:CACurrentMediaTime()];
  if ([_videoOutput hasNewPixelBufferForItemTime:outputItemTime]) {
    return [_videoOutput copyPixelBufferForItemTime:outputItemTime itemTimeForDisplay:NULL];
  } else {
    return NULL;
  }
}

The whole code can be found here:
https://github.com/cbenhagen/plugins/blob/video_player_macos_new/packages/video_player/video_player_macos/macos/Classes/FLTVideoPlayerPlugin.m

/cc @iskakaushik

[✓] Flutter (Channel master, 2.1.0-13.0.pre.416, on macOS 11.2.3 20D91 darwin-arm, locale en-CH)
    • Flutter version 2.1.0-13.0.pre.416 at /Users/ben/development/flutter
    • Framework revision b9638fb837 (11 hours ago), 2021-04-02 00:39:02 -0400
    • Engine revision bed3a4a7a0
    • Dart version 2.13.0 (build 2.13.0-192.0.dev)

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /Users/ben/Library/Android/sdk
    • Platform android-30, build-tools 30.0.2
    • Java binary at: /Users/ben/Library/Application
      Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/201.7199119/Android
      Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.4, Build version 12D4e
    • CocoaPods version 1.10.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.1)
    • Android Studio at /Users/ben/Library/Application
      Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/201.7199119/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 1.8.0_242-release-1644-b3-6915495)

[✓] VS Code (version 1.53.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.19.0

[✓] Connected device (3 available)
    • iPad von Ben (mobile) • 00008027-000C45CA0A62402E • ios            • iOS 14.4.2
    • macOS (desktop)       • macos                     • darwin-arm64   • macOS 11.2.3 20D91
      darwin-arm
    • Chrome (web)          • chrome                    • web-javascript • Google Chrome 89.0.4389.114

• No issues found!

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work lista: desktopRunning on desktopa: videoVideo playbackc: performanceRelates to speed or footprint issues (see "perf:" labels)engineflutter/engine related. See also e: labels.found in release: 2.0Found to occur in 2.0found in release: 2.1Found to occur in 2.1has reproducible stepsThe issue has been confirmed reproducible and is ready to work onperf: memoryPerformance issues related to memory

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions