Skip to content
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

Flutter engine crashes on some Android devices due to "Failed to setup Skia Gr context" #47804

Closed
yrom opened this issue Dec 26, 2019 · 102 comments
Closed
Assignees
Labels
c: crash Stack traces logged to the console c: regression It was better in the past than it is now customer: bytedance customer: crowd Affects or could affect many people, though not necessarily a specific customer. dependency: skia Skia team may need to help us e: device-specific Only manifests on certain devices engine flutter/engine repository. See also e: labels. platform-android Android applications specifically

Comments

@yrom
Copy link

yrom commented Dec 26, 2019

Steps to Reproduce

This crash was happened on users' Android phone. I don't know clear steps to reproduce.

User starts the FlutterActivity then the APP crashes immediately.

Devices:

  • Huawei DUB AL00A
  • Huawei DUB AL00
  • Honor BKK AL10
  • Huawei ARS AL00
  • Huawei DUB AL20

Android version: Android 8.1.0,level 27

I noticed that they are all Huawei phones, and the EMUI version is 8.x, some of which using the Qualcomm Snapdragon processor.


updated at 2020-1-3

After investigating, I found the root cause was the skia attemping to use GL_QCOM_TILED_RENDERING on these phones. Ssee https://skia-review.googlesource.com/c/skia/+/246282/2. But something went wrong as the logcat said.

If you are troubling on this issue, you can try to roll back the skia revision and use your local compiled flutter engine, before the flutter team fixed this issue.

Logs


W libEGL : [eglGetProcAddress] QCOM code detected: glEndTilingQCOM ... Returning NULL
W libEGL : [eglGetProcAddress] QCOM code detected: glStartTilingQCOM ... Returning NULL
E flutter : [ERROR:flutter/shell/gpu/gpu_surface_gl.cc(70)] Failed to setup Skia Gr context.
W libEGL : [eglGetProcAddress] QCOM code detected: glEndTilingQCOM ... Returning NULL
W libEGL : [eglGetProcAddress] QCOM code detected: glStartTilingQCOM ... Returning NULL

main thread stack trace:

1 io.flutter.embedding.engine.FlutterJNI.nativeSurfaceCreated(Native Method)
2 io.flutter.embedding.engine.FlutterJNI.onSurfaceCreated(FlutterJNI.java:3)
3 io.flutter.embedding.engine.renderer.FlutterRenderer.startRenderingToSurface(FlutterRenderer.java:16)
4 io.flutter.embedding.android.FlutterSurfaceView.connectSurfaceToRenderer(FlutterSurfaceView.java:3)
5 io.flutter.embedding.android.FlutterSurfaceView.b(FlutterSurfaceView.java:1)
6 io.flutter.embedding.android.FlutterSurfaceView$a.surfaceCreated(FlutterSurfaceView.java:4)
7 android.view.SurfaceView.updateSurface(SurfaceView.java:728)
8 android.view.SurfaceView$2.onPreDraw(SurfaceView.java:151)
9 android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:977)
10 android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2573)
11 android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1558)
12 android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7463)
13 android.view.Choreographer$CallbackRecord.run(Choreographer.java:1041)
14 android.view.Choreographer.doCallbacks(Choreographer.java:847)
15 android.view.Choreographer.doFrame(Choreographer.java:774)
16 android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1027)
17 android.os.Handler.handleCallback(Handler.java:809)
18 android.os.Handler.dispatchMessage(Handler.java:102)
19 android.os.Looper.loop(Looper.java:166)
20 android.app.ActivityThread.main(ActivityThread.java:7555)

1.gpu thread: signal SIGSEGV(SEGV_MAPERR)

#00 0x001682a8 /data/app/com.bilibili.comic-UlhrVZRG20zydm5ToI41uw==/lib/arm/libflutter.so [armeabi-v7a::8d3ed6bbd864323d41970181b0b00b84]
flutter::Rasterizer::Setup(std::__1::unique_ptr<flutter::Surface, std::__1::default_delete<flutter::Surface> >)
/b/s/w/ir/cache/builder/src/out/android_release/../../flutter/shell/common/rasterizer.cc:69:17
#01 0x0016ec67 /data/app/com.bilibili.comic-UlhrVZRG20zydm5ToI41uw==/lib/arm/libflutter.so [armeabi-v7a::8d3ed6bbd864323d41970181b0b00b84]
flutter::Shell::OnPlatformViewCreated(std::__1::unique_ptr<flutter::Surface, std::__1::default_delete<flutter::Surface> >)::$_8::operator()()
/b/s/w/ir/cache/builder/src/out/android_release/../../flutter/shell/common/shell.cc:566:23
auto fml::internal::CopyableLambda<flutter::Shell::OnPlatformViewCreated(std::__1::unique_ptr<flutter::Surface, std::__1::default_delete<flutter::Surface> >)::$_8>::operator()<>() const
/b/s/w/ir/cache/builder/src/out/android_release/../../flutter/fml/make_copyable.h:24:0
#02 0x00146755 /data/app/com.bilibili.comic-UlhrVZRG20zydm5ToI41uw==/lib/arm/libflutter.so [armeabi-v7a::8d3ed6bbd864323d41970181b0b00b84]
std::__1::function<void ()>::operator()() const
/b/s/w/ir/cache/builder/src/out/android_release/../../third_party/libcxx/include/functional:2419:12
fml::MessageLoopImpl::FlushTasks(fml::FlushType)
/b/s/w/ir/cache/builder/src/out/android_release/../../flutter/fml/message_loop_impl.cc:123:0
fml::MessageLoopImpl::RunExpiredTasksNow()
/b/s/w/ir/cache/builder/src/out/android_release/../../flutter/fml/message_loop_impl.cc:133:0
#03 0x00148489 /data/app/com.bilibili.comic-UlhrVZRG20zydm5ToI41uw==/lib/arm/libflutter.so [armeabi-v7a::8d3ed6bbd864323d41970181b0b00b84]
fml::MessageLoopAndroid::OnEventFired()
/b/s/w/ir/cache/builder/src/out/android_release/../../flutter/fml/platform/android/message_loop_android.cc:92:5
fml::MessageLoopAndroid::MessageLoopAndroid()::$_0::operator()(int, int, void*) const
/b/s/w/ir/cache/builder/src/out/android_release/../../flutter/fml/platform/android/message_loop_android.cc:42:0
fml::MessageLoopAndroid::MessageLoopAndroid()::$_0::__invoke(int, int, void*)
/b/s/w/ir/cache/builder/src/out/android_release/../../flutter/fml/platform/android/message_loop_android.cc:40:0
#04 0x0000ff09 /system/lib/libutils.so (_ZN7android6Looper9pollInnerEi+580) [armeabi-v8::862798b286f1ba97372696549a8bea80]
#05 0x0000fc2d /system/lib/libutils.so (_ZN7android6Looper8pollOnceEiPiS1_PPv+32) [armeabi-v8::862798b286f1ba97372696549a8bea80]
#06 0x0000c9e1 /system/lib/libandroid.so (ALooper_pollOnce+56) [armeabi-v8::2f44f33bd999188a75f397fa44228d46]
#07 0x00148561 /data/app/com.bilibili.comic-UlhrVZRG20zydm5ToI41uw==/lib/arm/libflutter.so [armeabi-v7a::8d3ed6bbd864323d41970181b0b00b84]
fml::MessageLoopAndroid::Run()
/b/s/w/ir/cache/builder/src/out/android_release/../../flutter/fml/platform/android/message_loop_android.cc:68:18
#08 0x00145adf /data/app/com.bilibili.comic-UlhrVZRG20zydm5ToI41uw==/lib/arm/libflutter.so [armeabi-v7a::8d3ed6bbd864323d41970181b0b00b84]
fml::MessageLoopImpl::DoRun()
/b/s/w/ir/cache/builder/src/out/android_release/../../flutter/fml/message_loop_impl.cc:92:3
fml::MessageLoop::Run()
/b/s/w/ir/cache/builder/src/out/android_release/../../flutter/fml/message_loop.cc:49:0
#09 0x001474a1 /data/app/com.bilibili.comic-UlhrVZRG20zydm5ToI41uw==/lib/arm/libflutter.so [armeabi-v7a::8d3ed6bbd864323d41970181b0b00b84]
fml::Thread::Thread(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::$_0::operator()() const
/b/s/w/ir/cache/builder/src/out/android_release/../../flutter/fml/thread.cc:34:10
decltype(std::__1::forward<fml::Thread::Thread(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::$_0>(fp)()) std::__1::__invoke<fml::Thread::Thread(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::$_0>(fml::Thread::Thread(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::$_0&&)
/b/s/w/ir/cache/builder/src/out/android_release/../../third_party/libcxx/include/type_traits:3530:0
void std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, fml::Thread::Thread(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::$_0>(std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, fml::Thread::Thread(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::$_0>&, std::__1::__tuple_indices<>)
/b/s/w/ir/cache/builder/src/out/android_release/../../third_party/libcxx/include/thread:341:0
void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, fml::Thread::Thread(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::$_0> >(void*)
/b/s/w/ir/cache/builder/src/out/android_release/../../third_party/libcxx/include/thread:351:0
#10 0x000473eb /system/lib/libc.so (_ZL15__pthread_startPv+22) [armeabi-v8::c38cb0ea3187a942d434b91b139f1edd]
#11 0x0001ad29 /system/lib/libc.so (__start_thread+32) [armeabi-v8::c38cb0ea3187a942d434b91b139f1edd]
[✓] Flutter (Channel stable, v1.12.13+hotfix.5, on Mac OS X 10.14.6 18G2022, locale zh-Hans-CN)
    • Flutter version 1.12.13+hotfix.5 at /Users/wangyongrong/Library/flutter
    • Framework revision 27321ebbad (2 weeks ago), 2019-12-10 18:15:01 -0800
    • Engine revision 2994f7e1e6
    • Dart version 2.7.0

 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /Users/wangyongrong/Documents/Android-SDK
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.2
    • ANDROID_HOME = /Users/wangyongrong/Documents/Android-SDK
    • Java binary at: /Applications/Android Studio 2.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
    • All Android licenses accepted.

[✓] VS Code (version 1.41.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.7.1

[✓] Connected device (1 available)
    • VOG AL10 • APH7N19329001298 • android-arm64 • Android 9 (API 28)

@yrom
Copy link
Author

yrom commented Dec 26, 2019

Workaround for this issue: enable software rendering

Initialize flutter with args before starting FlutterActivity:

FlutterMain.ensureInitializationComplete(context, new String[]{FlutterShellArgs.ARG_ENABLE_SOFTWARE_RENDERING});

Or

Intent flutterActivity = ...; // build intent
flutterActivity.put(FlutterShellArgs.ARG_KEY_ENABLE_SOFTWARE_RENDERING, true);
startActivity(flutterActivity);

@nuptdzs
Copy link

nuptdzs commented Dec 26, 2019

加了这个会有其他的影响么?
Will this have other effects?

@yrom
Copy link
Author

yrom commented Dec 26, 2019

加了这个会有其他的影响么?

页面会变卡,不过我发现只有EMUI 8.2.0 的手机上会崩,所有只针对这些手机开启这个选项,

The page will become stuck, but I found that only EMUI 8.2.0 phones will crash, so only turn on this option for these phones

@nuptdzs

@nuptdzs
Copy link

nuptdzs commented Dec 26, 2019

加了这个会有其他的影响么?

页面会变卡,不过我发现只有EMUI 8.2.0 的手机上会崩,所有只针对这些手机开启这个选项,@nuptdzs

今天上线突然遇到这个问题。只能先回退版本了,机型判断的话担心遗漏不敢这么处理。

Suddenly encountered this problem on the line today. I can only roll back the version first. If the model judges, I am afraid that I will not deal with it.

@yrom
Copy link
Author

yrom commented Dec 26, 2019

@nuptdzs 你回退到哪个版本不会崩?

@nuptdzs
Copy link

nuptdzs commented Dec 26, 2019

@nuptdzs 你回退到哪个版本不会崩?

1.10.7,理论上1.12以下都行。

1.10.7, theoretically below 1.12 will work.

@chg2015
Copy link

chg2015 commented Dec 27, 2019

@nuptdzs你回退到该版本不会崩溃?

1.10.7,理论上1.12以下都行。

我也遇到设个问题,怎么回退版本啊

I also encountered a problem, how can I roll back the version?

@iapicca iapicca added customer: crowd Affects or could affect many people, though not necessarily a specific customer. dependency: android Android team may need to help us e: device-specific Only manifests on certain devices c: crash Stack traces logged to the console platform-android Android applications specifically labels Dec 27, 2019
@iapicca
Copy link
Contributor

iapicca commented Dec 27, 2019

Hi @yrom @nuptdzs @chg2015
if you update your flutter version recently
you may want to run
flutter clean
flutter pub cache repair
let me know if the issue persists
thank you

@iapicca iapicca added dependency: skia Skia team may need to help us c: regression It was better in the past than it is now labels Dec 27, 2019
@ghostgzt
Copy link

me too!

@zQ4
Copy link

zQ4 commented Dec 27, 2019

Hi @yrom @nuptdzs @chg2015
if you update your flutter version recently
you may want to run
flutter clean
flutter pub cache repair
let me know if the issue persists
thank you

Hi @yrom @nuptdzs @chg2015
if you update your flutter version recently
you may want to run
flutter clean
flutter pub cache repair
let me know if the issue persists
thank you

no,荣耀 8c 不通过

@haodadaa
Copy link

Hi @yrom @nuptdzs @chg2015
if you update your flutter version recently
you may want to run
flutter clean
flutter pub cache repair
let me know if the issue persists
thank you

I also encountered a problem, and this command can not resolve.

@andisolo
Copy link

andisolo commented Jan 2, 2020

Workaround for this issue: enable software rendering

Initialize flutter with args before starting FlutterActivity:

FlutterMain.ensureInitializationComplete(context, new String[]{FlutterShellArgs.ARG_ENABLE_DART_PROFILING});

Or

Intent flutterActivity = ...; // build intent
flutterActivity.put(FlutterShellArgs.ARG_KEY_ENABLE_SOFTWARE_RENDERING, true);
startActivity(flutterActivity);

在app的onCreate里面加了这个还是不起作用

@yrom
Copy link
Author

yrom commented Jan 2, 2020

@andisolo what's the EMUI version on your phone?

@andisolo
Copy link

andisolo commented Jan 2, 2020

@andisolo what's the EMUI version on your phone?

设备型号:BKK-AL10
系统版本号:BKK-AL10 8.2.0.193(C00)
安卓sdk版本:27
处理器:arm64-v8a
emui版本:EmotionUI_8.2.0

@yrom
Copy link
Author

yrom commented Jan 2, 2020

@andisolo sorry,I make a mistake! updated the snippet:

FlutterMain.ensureInitializationComplete(context, new String[]{FlutterShellArgs.ARG_KEY_ENABLE_SOFTWARE_RENDERING});

@andisolo
Copy link

andisolo commented Jan 2, 2020

@andisolo sorry,I make a mistake! updated the snippet:

FlutterMain.ensureInitializationComplete(context, new String[]{FlutterShellArgs.ARG_KEY_ENABLE_SOFTWARE_RENDERING});

我按照你所说的修改了,现在启动的错误日志如下:
[ERROR:flutter/runtime/dart_vm_data.cc(18)] VM snapshot invalid and could not be inferred from settings.
[ERROR:flutter/runtime/dart_vm.cc(241)] Could not setup VM data to bootstrap the VM from.
[ERROR:flutter/runtime/dart_vm_lifecycle.cc(84)] Could not create Dart VM instance.

@yrom
Copy link
Author

yrom commented Jan 2, 2020

The FlutterShellArgs.ARG_KEY_ENABLE_SOFTWARE_RENDERING should be FlutterShellArgs.ARG_ENABLE_SOFTWARE_RENDERING, so sorry..

@andisolo
Copy link

andisolo commented Jan 2, 2020

好了,非常感谢.

@andisolo
Copy link

andisolo commented Jan 2, 2020

The FlutterShellArgs.ARG_KEY_ENABLE_SOFTWARE_RENDERING should be FlutterShellArgs.ARG_ENABLE_SOFTWARE_RENDERING, so sorry..

由遇到了和#47765 一样的错误,你知道怎么解决吗?

@yxwandroid
Copy link

遇到同样的问题

@yxwandroid
Copy link

@andisolo 你解决了吗

@zzy216
Copy link

zzy216 commented Jan 2, 2020

Workaround for this issue: enable software rendering

Initialize flutter with args before starting FlutterActivity:

FlutterMain.ensureInitializationComplete(context, new String[]{FlutterShellArgs.ARG_ENABLE_SOFTWARE_RENDERING});

Or

Intent flutterActivity = ...; // build intent
flutterActivity.put(FlutterShellArgs.ARG_KEY_ENABLE_SOFTWARE_RENDERING, true);
startActivity(flutterActivity);

这个加在哪个文件呀

@tvolkert
Copy link
Contributor

tvolkert commented Jan 28, 2020

The performance issues on those phones may also be improved by https://skia.googlesource.com/skia/+/1321a3d, which will be included in the next release.

@xclud
Copy link
Contributor

xclud commented Feb 4, 2020

hello everyone,
new stable version has released, v1.12.13+hotfix.7-stable.
Can anyone check if the problem with Huawei is fixed in this version or not

Its significantly slow on my Huawei Honor 8C.

@liyuqian
Copy link
Contributor

liyuqian commented Feb 5, 2020

@godofredoc @GaryQian : we might need to add the 2 Huawei device to our device lab to continuously monitor this performance regression.

@iapicca
Copy link
Contributor

iapicca commented Feb 6, 2020

Could everyone who still has this problem please file a new issue with the exact descriptions what happens, logs and the output of 'flutter doctor -v' please.
All system setups can be slightly different so it's always better to open new issues and reference related issues.

@amrosama2020
Copy link

The performance issues on those phones may also be improved by https://skia.googlesource.com/skia/+/1321a3d, which will be included in the next release.

Any idea when the next release would be? this info would be helpful to decide on what to do.

@liyuqian
Copy link
Contributor

@amrosama2020 : Flutter has a new release version roughly every quarter (3 months). Our last one is around December so the next one should be around March.

@zsunkun
Copy link
Contributor

zsunkun commented Apr 17, 2020

I still have this problem with version 1.12.13+hotfix8,Can not be reproduced locally.
As @singun-lxd mentioned,#51447,I think they have the same problem.

@Hixie
Copy link
Contributor

Hixie commented Apr 21, 2020

cc @jason-simmons Any chance you can take a look at this one? Thanks!

@jason-simmons
Copy link
Member

@zoeyfan Is there a known way to reproduce this? Skia GrContext setup failures are typically due to errors reported by the device's graphics driver, so this may be specific to a particular device model and OS version.

@zoeyfan
Copy link

zoeyfan commented Apr 22, 2020

@zsunkun, @WATER1350, @linxuebin1990,@Qxyat. Would you please provide a particular device model and its OS version so our team can look into this issue?

@zsunkun
Copy link
Contributor

zsunkun commented Apr 22, 2020

@zsunkun, @WATER1350, @linxuebin1990,@Qxyat. Would you please provide a particular device model and its OS version so our team can look into this issue?

@jason-simmons @zoeyfan
device model:
image
os version:
image

@GaryQian
Copy link
Contributor

Although the crash error is the same, it looks to me like this may have a different cause than the original bug filed here since this seems to be more OS specific as well as device specific.

I'm going to merge the continuation of this issue with #51447 and close this one.

@zsunkun I will reproduce your useful graphs in the other issue. Thanks!

@lionoggo
Copy link

lionoggo commented Oct 14, 2020

@yrom  How to specify the local skia when compiling the engine?

@github-actions
Copy link

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 flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
c: crash Stack traces logged to the console c: regression It was better in the past than it is now customer: bytedance customer: crowd Affects or could affect many people, though not necessarily a specific customer. dependency: skia Skia team may need to help us e: device-specific Only manifests on certain devices engine flutter/engine repository. See also e: labels. platform-android Android applications specifically
Projects
None yet
Development

No branches or pull requests