-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
flutter/engine
#54056Labels
a: platform-viewsEmbedding Android/iOS views in Flutter appsEmbedding Android/iOS views in Flutter appsfound in release: 3.22Found to occur in 3.22Found to occur in 3.22found in release: 3.24Found to occur in 3.24Found to occur in 3.24has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onperf: memoryPerformance issues related to memoryPerformance issues related to memoryplatform-iosiOS applications specificallyiOS applications specificallyr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-iosOwned by iOS platform teamOwned by iOS platform team
Description
Steps to reproduce
Hi Team,
We're facing the memory leak when hosting the platform view with UIImageView.
Steps:
- Open and scroll up and down slightly, memory gets bumped and goes high (100kb to 600 Mib).
- Tap the floating action button, same view to open in showModalBottomSheet.
- Try to scroll the view, scrolling get junk and can't able to scroll
- Memory goes upto (600 Mib to 1.8Gb)
- After closing the sheet still the memory persist and never memory gets come down.
Profiling : I have attached the profiling video and project. Please look into it
Device Tested
Mobile: (Physical Device) iPhone 14
version: 17.5.1
Expected results
Memory leak needs to be resolve
Actual results
Getting memory leak and can't able to access the screen it total junky
Code sample
Code sample
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text("Native view Example"),
),
body: const NativeViewList(),
floatingActionButton: Builder(builder: (builderContext) {
return FloatingActionButton(
onPressed: () async {
await showModalBottomSheet(
context: builderContext,
isScrollControlled: true,
useSafeArea: true,
isDismissible: true,
clipBehavior: Clip.antiAlias,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16)),
builder: (context) {
return const NativeViewList();
},
);
},
);
}),
),
);
}
}
class NativeViewList extends StatelessWidget {
const NativeViewList({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
children: [
Container(height: 100, color: Colors.green),
Expanded(
child: ListView.separated(
itemCount: 150,
separatorBuilder: (context, index) {
return const SizedBox(height: 10);
},
itemBuilder: (context, index) {
// This is used in the platform side to register the view.
const String viewType = '<native_view>';
// Pass parameters to the platform side.
final Map<String, dynamic> creationParams = <String, dynamic>{};
return Stack(
alignment: Alignment.bottomCenter,
children: [
Stack(
children: [
Container(
width: 300,
height: 210,
color: Colors.red,
),
Container(
width: 300,
height: 210,
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
border: Border.all(color: Colors.grey)),
child: UiKitView(
viewType: viewType,
layoutDirection: TextDirection.ltr,
creationParams: creationParams,
creationParamsCodec: const StandardMessageCodec(),
),
),
],
),
Text("${index}"),
Container(
child: Text("Hello"),
)
],
);
},
),
),
Container(height: 100, color: Colors.amber)
],
),
);
}
}Screenshots or Video
Profiling Video
Screen.Recording.2024-07-20.at.2.05.17.AM.mov
Project File
Logs
Flutter Doctor output
Doctor output
bala@bala native_view_project % flutter doctor -v
[✓] Flutter (Channel stable, 3.22.3, on macOS 14.5 23F79 darwin-arm64, locale en-IN)
• Flutter version 3.22.3 on channel stable at /Users/bala-12858/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision b0850beeb2 (3 days ago), 2024-07-16 21:43:41 -0700
• Engine revision 235db911ba
• Dart version 3.4.4
• DevTools version 2.34.3
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/bala-12858/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.10+0-17.0.10b1087.21-11609105)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 15.0.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15A507
• CocoaPods version 1.15.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2024.1)
• 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.10+0-17.0.10b1087.21-11609105)
[✓] VS Code (version 1.91.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.92.0
[✓] Connected device (6 available)
• Balasubramani-12858-WL (mobile) • 00008110-0018589E0123A01E • ios • iOS 17.5.1 21F90
• iPhone 13 Pro (mobile) • C1C2041D-CC82-48CF-A780-6D184657147B • ios • com.apple.CoreSimulator.SimRuntime.iOS-17-0 (simulator)
• iPhone 15 Pro Max (mobile) • 231E8070-BC78-4E89-B3B7-6A2BF5820A5F • ios • com.apple.CoreSimulator.SimRuntime.iOS-17-0 (simulator)
• macOS (desktop) • macos • darwin-arm64 • macOS 14.5 23F79 darwin-arm64
• Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 14.5 23F79 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 126.0.6478.127
[✓] Network resources
• All expected network resources are available.
• No issues found!Metadata
Metadata
Assignees
Labels
a: platform-viewsEmbedding Android/iOS views in Flutter appsEmbedding Android/iOS views in Flutter appsfound in release: 3.22Found to occur in 3.22Found to occur in 3.22found in release: 3.24Found to occur in 3.24Found to occur in 3.24has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onperf: memoryPerformance issues related to memoryPerformance issues related to memoryplatform-iosiOS applications specificallyiOS applications specificallyr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-iosOwned by iOS platform teamOwned by iOS platform team