-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
Steps to reproduce
-
Clone https://github.com/rohit11/Flutter_PlatformView.
I stumbled upon this public example when trying to reproduce this issue without setting up too much myself, and it perfectly illustrates the problem. Thanks rohit11 ;) -
Replace myapp.dart with the one from CodeSample
-
Tap the button
Expected results
Tapping the Button does not affect the devices memory, as the button itself has no logic in its onPressed.
Actual results
Tapping the Button increases the apps memory usage indefinitely until it is killed by the os.
Code sample
import 'package:flutter/material.dart';
class MyApp extends StatelessWidget {
Widget build(context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('Platform View'),
),
body: SafeArea(child: Stack(children: [
SizedBox(
width: 380,
height: 380,
child: UiKitView(
viewType: 'NativeView',
),
),
Stack(
children: List<Widget>.generate(10000, (index) {
// The problem already happens with a small amount of widgets.
// Using an excessive amount of widgets is just to make the problem more evident.
return Text("Lots of Texts represent a Widget with complex components.");
}),
),
Align(
alignment: Alignment.bottomCenter,
child:
TextButton(
child: Text("Button"),
onPressed: () {
print("Tap ${DateTime.now()}");
},
),
),
],
),
),
),
);
}
}
Screenshots or Video
As far as I can tell, there are IOGPUMetalResources allocated, which are never released and persist until the App runs out of memory?

Logs
No response
Flutter Doctor output
[!] Flutter (Channel [user-branch], 3.24.1, on macOS 15.0 24A5320a darwin-arm64, locale en-DE)
! Flutter version 3.24.1 on channel [user-branch] at /Users/heidenthal/Projects/flutter
Currently on an unknown channel. Run flutter channel to switch to an official channel.
If that doesn't fix the issue, reinstall Flutter by following instructions at https://flutter.dev/setup.
! Upstream repository unknown source is not a standard remote.
Set environment variable "FLUTTER_GIT_URL" to unknown source to dismiss this error.
• Framework revision 5874a72 (2 weeks ago), 2024-08-20 16:46:00 -0500
• Engine revision c9b9d5780d
• Dart version 3.5.1
• DevTools version 2.37.2
• If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/heidenthal/Library/Android/sdk
• Platform android-34, build-tools 34.0.0
• 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.6b829.9-10027231)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 16.0)
• Xcode at /Users/heidenthal/Downloads/Xcode-beta.app/Contents/Developer
• Build 16A5202i
• CocoaPods version 1.15.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2022.3)
• 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.6b829.9-10027231)
[✓] VS Code (version 1.92.2)
• VS Code at /Users/heidenthal/Downloads/Visual Studio Code.app/Contents
• Flutter extension can be installed from:
🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[✓] Connected device (5 available)
• Heidis iPhone (mobile) • 00008110-000E60AA0C40401E • ios • iOS 18.0 22A5350a
• iPhone14Pro (mobile) • 00008120-001251C20A38C01E • ios • iOS 17.3 21D50
• macOS (desktop) • macos • darwin-arm64 • macOS 15.0 24A5320a darwin-arm64
• Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 15.0 24A5320a darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 128.0.6613.114
[✓] Network resources
• All expected network resources are available.
Note
Please note, that I am using a flutter 3.24.1 user-branch in the flutter doctor output as I have played around with this bug for a while. It does happen on the stable 3.24.1 version as well.
I am also currently using the MacOS Sequoia Beta including the xCode 16 Beta, but had the same issue a few weeks before when I was still using the official MacOS release with xCode 15.4.
The memory also only appears in the xCode memory profiler, not in the flutter profiler.