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
[image_picker with google_maps_flutter] Emulator Crash after getImage - Failed to setup Skia Gr context. #63663
Comments
Same with Android API 28. |
on my tested real devices (Huawai P30 Pro and Google Pixel 3) is all fine. |
Hi @maerlynflagg , |
Hi @maerlynflagg |
Here my flutter doctor output:
|
currently i can't give you a example. LogW/de.ntag.lmng(25915): Accessing hidden method Landroid/view/accessibility/AccessibilityNodeInfo;->getSourceNodeId()J (greylist, reflection, allowed) Build fingerprint: 'google/sdk_gphone_x86/generic_x86:10/QSR1.190920.001/5891938:user/release-keys' |
Hi @maerlynflagg main.dartimport 'dart:io';
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Material App',
theme: ThemeData.dark(),
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
File _image;
final picker = ImagePicker();
Future getImage() async {
final pickedFile = await picker.getImage(
source: ImageSource.camera,
maxHeight: 1024,
maxWidth: 1024,
imageQuality: 100);
setState(() {
_image = File(pickedFile.path);
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Image Picker Example'),
),
body: Center(
child: _image == null ? Text('No image selected.') : Image.file(_image),
),
floatingActionButton: FloatingActionButton(
onPressed: getImage,
tooltip: 'Pick Image',
child: Icon(Icons.add_a_photo),
),
);
}
}
logs
flutter doctor -v
|
i tried a new flutter project (the counter example) with only the image picker plugin. on increase the counter , i take the photo and it works without crash after getImage. currently i try to find óut more informations. |
so I guess now you can close the issue |
i'm not sure. yes, in the simple starter app flutter create the getImage worked in emulator, but in a bigger flutter app, which have no displayed error, it crashed at the same line. side note: on beginning of my app, all worked fine. i concentrated to other pages to complete. so i hoped, the new picker version fixed something, but the update and the new function getImage hasn't any effect. now i compared the simple app with my existing app. i changed
. so since last month changed the flutter version to 1.20.1. it looks like a unknown thing, which causes the issue on pickImage / getImage for bigger flutter apps. i hope, only emulator crashes and not real devices. |
so now i downgrade to flutter 1.17.5 and the emulator worked fine. no crash on getImage. also i think it is a problem between Flutter 1.20.1 / 1.20.2 and imager_picker on bigger flutter apps. |
after upgrading back to flutter version 1.20.2 it crashes on getImage. So whats the special thing between flutter 1.17.5 and 1.20.1/1.20.2 ? is there something, which i'm not noticed to migrate, that all is working? |
Hi, i'm having the same problem: app crashs after getImage() on AVD (emulator), on any flutter version after 1.17.5 (stable). I also tried on Master Channel but the problem persists. I can't reproduce anymore because I downgrade flutter to 1.17.5 (stable), but I noticed something wierd: This problem only does't happen at the "begining" of the app. I will try to explain that: My aplication has a signin page at the begining, where user can pick an image from gallery to use as profile avatar. At this point the ImagePicker.getImage() works perfectly, no crashs. But, when the user login, he goes to a "main page" where there are some interactive resources like google maps API. After that the user can navigate (navigator pushnamed) to "My profile" screen, where he can change his personal info and also change his avatar picture. But, at this point when it runs getImage() the app crashs. I don't know why but maybe it is related to others plugins or imports, or maybe to the more complexity logic existing at this aplication point. To let things more clear, these are the "3rd-party" imports at signin page:
Any ideas? |
Hi @maerlynflagg |
today i tested some things. i comment out some things and comment in. now, i have a point, where i got no crash. i will explain: i have order details page. on this page is a map. from der i can enter edit mode page without map and from there a page to take some photos and give the photos tags. i tried some things, so i tried to remove the map from view and replaced with a simple Container(). after this change, i haven't any crash on the take photo page. it works fine. so flutter 1.20.2, image_picker and google_maps_flutter is a constellation, which crashes the emulator, maybe real devices. which flutter 1.75 there is no problem on this constellation. i'm using google maps:
|
if i using this in visual studio code:
it crashed on opening the details page with the map. |
it is not a private app, so i can't. |
upgrade to google_maps_flutter: ^0.5.30 doesn't help. i see, flutter.dev is the developer and publisher of both plugins google_maps_flutter and image_picker. so i hope, you can better find the conflict. |
Hi @maerlynflagg |
I have a sample for you. in the pubspec.yaml add following:
Don't forget for Google Maps the API Keys in AndroidManifest.xml and AppDelegate.swift. replace YOURAPIKEY with your key. Android Manifest
App Delegate
now replace your main.dart. main.dart
now you can run the app in android emulator. for example Google Pixel 2 API 29. it crashes after getImage. |
I reproduced the image picker exemple and the app sometimes (50%) crashes on getImage, and in big apps the percentage of chrased is 100%, its happen only in android devices, iOs is ok. flutter doctor -v [✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3) [✓] Xcode - develop for iOS and macOS (Xcode 11.7) [✓] Android Studio (version 4.0) [✓] VS Code (version 1.49.0) [✓] Connected device (1 available) • No issues found!` |
I tried running the maps/image_picker example app from #63663 (comment) but was unable to reproduce this on the devices i tried (Moto G4, Nexus 5X, Pixel 3) or on various emulator environments. The emulators I used were hosted on Mac and Linux, but i noticed that the I also tried symbolizing the x86 stack trace from #63663 (comment) but was unable to get usable symbols from there. |
For me it only failed in Emulator with Windows 10. My app didn't crash in real phone. |
I was able to reproduce this on an Android emulator running on Windows. When the app returns after capturing the image, the call to Something later tries to use the invalid surface, resulting in the crash. |
yes, like i said in the origin post, it is a emulator crash. on real device it currently looks all okay. but there is another thread with issue of image_picker on device #63217 . this crash is since Flutter 1.20.x. the crash is only if a map is rendered. if the map is not rendered, all is fine. |
you can find a solution for some Skia Gr context issues, if you google:
but in this case, this is not a solution, because if this flag enabled and you open the view in your app, which included the map, it crashes directly the emulator. so, currently it isn't fun to develope an app, if you use one or all combinations of plugins above with Flutter 1.20.x. |
In the Android emulator, the call to When the Flutter app initially launches on the emulator it sees a GLES 3.1 version string. But after starting the camera activity and returning to the main Flutter activity, Skia's
So in a call sequence like this:
the second This issue started happening as a side effect of a refactoring of the Android EGL context/surface lifecycle (flutter/engine@fafccf8) Before that, the Flutter engine would destroy its I'll look for a way to work around this when the engine is running on an Android emulator. |
so if i combine your answer with the origin issue, so the version check fails only, if you using google maps. without google maps, camera and local auth working fine in Android emulator. hope it will be fixed for better working. |
…GL version strings Some versions of the Android emulator EGL implementation will only update the GL_VERSION string when the process calls eglMakeCurrent on an EGLContext for the first time. If you select a GLES2 context, then a GLES1 context, and then the original GLES2 context, the version string will not be updated by the second eglMakeCurrent(GLES2) call. So if a GLES1 context was previously current, then when the engine makes its GLES2 context current Skia will continue to see the GLES1 version string and will fail to build a GrGLInterface. This workaround checks for the emulator GL renderer and creates a new context to force a version string update before making the GrGLInterface. See internal bug b/168748787 Fixes flutter/flutter#63663
If PlatformView::CreateRenderingSurface produces a surface that is not fully initialized, then the invalid surface will cause crashes when it is eventually used by the rasterizer. See flutter/flutter#63663
Please can give me guidance how to solve this issue as i am new in flutter and i want use google map and image picker through camera in my app. |
i upgraded to Flutter 1.22.0 today. so there is no crash in Windows Emulator Android, because now i get a PlatformException. Camera is not aviable. looks like a workaround by Flutter. EDIT Okay looks like a bug, cause on my real device Google Pixel 3 i got the PlatformException "No cameras available for taking pictures." too. EDIT 2 i upgraded again today, cleaned today again, build again and delete and installed app again on emulator. now the PlatformException is solved. But for the Skia Gr context issue on Windows Android Emulator i haven't a good workaround. some workarounds i tested wasn't good in the release build test. |
this issue is still persisiting |
Could everyone who still has this problem please file a new issue with the exact description of what happens, logs, and the output of |
currently i haven't a crash like i described in the first posts. using:
|
Hello, I am facing the same issue. flutter 1.22.5 I am not using local_auth. Can you please help me? |
Hi, i'm having the same problem, but by now I downgraded to flutter 1.17. I'm still waiting for some solution... |
@rafaelsimonassi @ligoriofc |
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 |
Usage
PickedFile imageFile = await _imagePicker.getImage(source: ImageSource.camera, maxHeight: 1024, maxWidth: 1024, imageQuality: 100);
Expected results:
i can work completely with emulator like before.
Actual results:
very short time after i confirmed the taken photo, the app crashes. between confirm and crash i see black screen.
the crash thrown with image_picker: ^0.6.3+1 and image_picker: ^0.6.7+4.
it crashes because a null pointer. possible reason is the Skia Gr context. i tested Pixel 2 , Pixel 3 and Nexus 5X with API 29 as emulator.
for some weeks, i haven't any issue to take photo. i think it was before Flutter 1.20.1.
Crash Log
The text was updated successfully, but these errors were encountered: