New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[IOS] Image.toByteData() is still super slow on Flutter 3.3.7 #114788
Comments
@fullflash |
An example was already shown in the previous issues that seems to have been incorrectly closed. It has significant details like benchmarks times, and additional discussion. Maybe consider re-opening it? It's quite frustrating to developers when they take the time to log proper details about a bug, it is closed prematurely, then they are asked to provide details again about the same issue: import 'dart:ui' as ui;
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
final GlobalKey sharePageKey = GlobalKey();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: RepaintBoundary(
key: sharePageKey,
child: Column(
children: [
Text(List.generate(200, (index) => "Text").join("#")),
Image.network(
"http://pic1.win4000.com/wallpaper/2020-10-10/5f811214aa09e.jpg",
width: double.infinity,
),
],
),
),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
createImage();
},
child: const Text("create"),
),
);
}
createImage() async {
final stopWatch = Stopwatch();
stopWatch.start();
debugPrint("tim0 ${DateTime.now()}");
BuildContext? buildContext = sharePageKey.currentContext;
if (null != buildContext) {
RenderRepaintBoundary boundary =
buildContext.findRenderObject() as RenderRepaintBoundary;
ui.Image image = await boundary.toImage(pixelRatio: 5);
ByteData? byteData =
await image.toByteData(format: ui.ImageByteFormat.png);
if (byteData != null) {
var pngBytes = byteData.buffer.asUint8List();
debugPrint("time elapsed in (ms) = ${stopWatch.elapsedMilliseconds}");
}
stopWatch.stop();
}
}
} |
Thanks for the feedback @esDotDev. Using code sample provided above, I do see difference in stable version as compared to master, but it is not the same / close to what OP mentioned:
Below are the numbers I got running on iOS simulator:
Below are the numbers from stable version running on physical device (iphone 6s) which as compared to above are significantly less.
Can you share the variance you are seeing ? Based on that we can decide to reopen the original issue. |
Nice, so it seems like the issue has been fixed on master? 3.3.7 is still extremely slow, but at least a fix is coming :) |
flutter/engine#34568 solved the issue, but the stable branch was not merged, so I had to spend four months at 2.10.5. |
Very strange. In 3.3.8, the pull request is not merged, but the speed has been improved. |
Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now. |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
await image.toByteData(format: ImageByteFormat.png);
After Flutter 3 update it becames SUPER slow on ios. on android it works super fast
on each flutter new version it gets worst.
Flutter 3.3.7 android 7000 ms
Flutter 3 19000ms
Flutter 3.3.7 29000ms
there was an issue that was closed but no fixes still.
#106773
The text was updated successfully, but these errors were encountered: