-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
flutter/engine
#41168Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: releaseChallenges faced when attempting to productionize an appChallenges faced when attempting to productionize an appc: crashStack traces logged to the consoleStack traces logged to the consolee: impellerImpeller rendering backend issues and features requestsImpeller rendering backend issues and features requestsengineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.found in release: 3.7Found to occur in 3.7Found to occur in 3.7found in release: 3.9Found to occur in 3.9Found to occur in 3.9has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onplatform-iosiOS applications specificallyiOS applications specificallyr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version
Description
Steps to Reproduce
- build in release mode with Impeller enabled.
- when you run the application on an actual iOS device, an exception will occur at
toImageSync. - the first time you install the app on the actual device and run it for the first time, the exception may not occur. Try to kill the app once and then run it again.
If you disable Impeller, this exception will not occur, so I think Impeller is related to this.
Expected results:
Must not result in a null exception.
Actual results:
As you can see in the attached log, I get an Exception and cannot draw the image.
Code sample
Here is a sample repository.
https://github.com/KoheiKanagu/flutter_issue_to_image_sync
import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({
super.key,
});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Center(
child: FutureBuilder(
builder: (context, snapshot) {
if (snapshot.hasError) {
print(snapshot.error);
}
final data = snapshot.data;
if (data != null) {
return Image(
image: data,
);
}
return const CircularProgressIndicator();
},
future: canvasToMemoryImage(16),
),
),
),
);
}
}
Future<MemoryImage> canvasToMemoryImage(int size) async {
final paint = Paint()..color = Colors.red;
final recorder = PictureRecorder();
final canvas = Canvas(recorder);
canvas.drawCircle(Offset.zero, 10, paint);
final picture = recorder.endRecording();
final image = picture.toImageSync(size, size); // Image was null
final byteData = await image.toByteData(
format: ImageByteFormat.png,
);
final result = MemoryImage(
byteData?.buffer.asUint8List() ?? Uint8List(0),
);
return result;
}Logs
This log was checked with the macOS console app.
12:10:50.943691+0900 Runner [VERBOSE-2:image_encoding_impeller.cc(66)] Image was null.
12:10:50.943852+0900 Runner [VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: Null check operator used on a null value
#0 _Image.toByteData.<anonymous closure>.<anonymous closure> (dart:ui/painting.dart:1891)
flutter doctor -v
[✓] Flutter (Channel stable, 3.7.9, on macOS 13.2.1 22D68 darwin-arm64, locale ja-JP)
• Flutter version 3.7.9 on channel stable at /Users/kingu/fvm/versions/stable
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 62bd79521d (5 days ago), 2023-03-30 10:59:36 -0700
• Engine revision ec975089ac
• Dart version 2.19.6
• DevTools version 2.20.1
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
• Android SDK at /Users/kingu/Library/Android/sdk
• Platform android-33, build-tools 33.0.2
• ANDROID_SDK_ROOT = /Users/kingu/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
• Xcode at /Applications/Xcode-14.2.0.app/Contents/Developer
• Build 14C18
• CocoaPods version 1.12.0
[✓] Chrome - develop for the web
• CHROME_EXECUTABLE = /Users/kingu/Develop/global/dotfiles/google-chrome-unsafe.sh
[✓] Android Studio (version 2022.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 11.0.15+0-b2043.56-8887301)
[✓] VS Code (version 1.77.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.60.0
[✓] VS Code (version 1.78.0-insider)
• VS Code at /Applications/Visual Studio Code - Insiders.app/Contents
• Flutter extension version 3.62.0
[✓] Connected device (5 available)
• KingPad K10 (mobile) • VKK104GJP0000443 • android-arm64 • Android 10 (API 29)
• KiPhone 14 Pro (mobile) • 00008120-001159C40CEB401E • ios • iOS 16.3.1 20D67
• iPad (10th generation) (mobile) • 5D03F545-E381-4681-86B9-FF00A4C904AF • ios • com.apple.CoreSimulator.SimRuntime.iOS-16-2 (simulator)
• macOS (desktop) • macos • darwin-arm64 • macOS 13.2.1 22D68 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 111.0.5563.146
! Error: Apple Watch Series 5 needs to connect to determine its availability. Check the connection between the device and its companion iPhone, and the connection between the iPhone and Xcode. Both devices may also need
to be restarted and unlocked. (code 1)
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: releaseChallenges faced when attempting to productionize an appChallenges faced when attempting to productionize an appc: crashStack traces logged to the consoleStack traces logged to the consolee: impellerImpeller rendering backend issues and features requestsImpeller rendering backend issues and features requestsengineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.found in release: 3.7Found to occur in 3.7Found to occur in 3.7found in release: 3.9Found to occur in 3.9Found to occur in 3.9has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onplatform-iosiOS applications specificallyiOS applications specificallyr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version