Closed Passer-by closed 6 months ago
similar with this issue #103870
I've made some special handle for this issue
FlutterRenderer.onTrimMemory seems to be from https://github.com/flutter/engine/commit/031fa76
Trying to run the android project, I get the following error.
2022-09-23 18:38:32.527 12234-12258/com.google.android.gsf W/GmsClient: IGmsServiceBroker.getService failed
android.os.DeadObjectException: Transaction failed on small parcel; remote process probably died, but this could also be caused by running out of binder buffe
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(BinderProxy.java:584)
at com.google.android.gms.common.internal.IGmsServiceBroker$Stub$zza.getService(IGmsServiceBroker.java:13)
at com.google.android.gms.common.internal.zzr.zza(GmsClientTracer.java:3)
at com.google.android.gms.common.internal.BaseGmsClient.getRemoteService(BaseGmsClient.java:269)
at com.google.android.gms.common.api.internal.zzbb.run(GoogleApiManager.java:11)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at com.google.android.gms.libs.punchclock.threads.TracingHandler.dispatchMessageTraced(TracingHandler.java:14)
at com.google.android.gms.libs.punchclock.threads.TracingHandler.dispatchMessage(TracingHandler.java:12)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.os.HandlerThread.run(HandlerThread.java:67)
Not sure what the issue is. But I'll still label this issue for further insights from the team.
Trying to run the android project, I get the following error.
2022-09-23 18:38:32.527 12234-12258/com.google.android.gsf W/GmsClient: IGmsServiceBroker.getService failed android.os.DeadObjectException: Transaction failed on small parcel; remote process probably died, but this could also be caused by running out of binder buffe at android.os.BinderProxy.transactNative(Native Method) at android.os.BinderProxy.transact(BinderProxy.java:584) at com.google.android.gms.common.internal.IGmsServiceBroker$Stub$zza.getService(IGmsServiceBroker.java:13) at com.google.android.gms.common.internal.zzr.zza(GmsClientTracer.java:3) at com.google.android.gms.common.internal.BaseGmsClient.getRemoteService(BaseGmsClient.java:269) at com.google.android.gms.common.api.internal.zzbb.run(GoogleApiManager.java:11) at android.os.Handler.handleCallback(Handler.java:942) at android.os.Handler.dispatchMessage(Handler.java:99) at com.google.android.gms.libs.punchclock.threads.TracingHandler.dispatchMessageTraced(TracingHandler.java:14) at com.google.android.gms.libs.punchclock.threads.TracingHandler.dispatchMessage(TracingHandler.java:12) at android.os.Looper.loopOnce(Looper.java:201) at android.os.Looper.loop(Looper.java:288) at android.os.HandlerThread.run(HandlerThread.java:67)
Not sure what the issue is. But I'll still label this issue for further insights from the team.
Sorry, this crash is not the same as mine and I think this crash has nothing to do with Flutter
This crash is appearing when clicking on the button and the Flutter view loads. Not in the way you are describing :)
This crash is appearing when clicking on the button and the Flutter view loads. Not in the way you are describing :)
wait for me to try my demo again
This crash is appearing when clicking on the button and the Flutter view loads. Not in the way you are describing :)
I apologize for my carelessness. I updated the demo(webview_flutter -> inappwebview add network permissions ) and provided a video of the crash
These are the error logs I am getting after using your latest code. Though the app is crashing before I actually get into the foreground (observed through the terminal).
These are the error logs I am getting after using your latest code. Though the app is crashing before I actually get into the foreground (observed through the terminal).
Logs (tail)
Try this, will it still crash ?
Already have that commented with the code I used to reproduce :D
This crash is happening for me on Flutter 3.7.0. It's only happening is the background on Motorolla devices running Android 11. I'm using the google_mobile_ads
plugin.
Stack trace:
drawRenderNode called on a context with no surface!
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
pid: 0, tid: 12847 >>> com.redacted.redacted <<<
backtrace:
#00 pc 0x000000000004e30c /apex/com.android.runtime/lib64/bionic/libc.so (abort+164)
#01 pc 0x000000000055f660 /apex/com.android.art/lib64/libart.so (art::Runtime::Abort(char const*)+2308)
#02 pc 0x0000000000013978 /system/lib64/libbase.so (android::base::SetAborter(std::__1::function<void (char const*)>&&)::$_3::__invoke(char const*)+76)
#03 pc 0x0000000000006e18 /system/lib64/liblog.so (__android_log_assert+336)
#04 pc 0x000000000021502c /system/lib64/libhwui.so (android::uirenderer::skiapipeline::SkiaOpenGLPipeline::getFrame()+52)
#05 pc 0x000000000021e0e8 /system/lib64/libhwui.so (android::uirenderer::renderthread::CanvasContext::draw()+188)
#06 pc 0x0000000000220770 /system/lib64/libhwui.so (_ZNSt3__110__function6__funcIZN7android10uirenderer12renderthread13DrawFrameTask11postAndWaitEvE3$_0NS_9allocatorIS6_EEFvvEEclEv$c303f2d2360db58ed70a2d0ac7ed911b+480)
#07 pc 0x000000000020edac /system/lib64/libhwui.so (android::uirenderer::WorkQueue::process()+220)
#08 pc 0x00000000002301f8 /system/lib64/libhwui.so (android::uirenderer::renderthread::RenderThread::threadLoop()+88)
#09 pc 0x00000000000154d0 /system/lib64/libutils.so (android::Thread::_threadLoop(void*)+260)
#10 pc 0x0000000000014d94 /system/lib64/libutils.so (thread_data_t::trampoline(thread_data_t const*)+412)
#11 pc 0x00000000000afc6c /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+64)
#12 pc 0x00000000000502c8 /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64)
This crash is happening for me on Flutter 3.7.0. It's only happening is the background on Motorolla devices running Android 11. I'm using the
google_mobile_ads
plugin.Stack trace:
drawRenderNode called on a context with no surface!
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** pid: 0, tid: 12847 >>> com.redacted.redacted <<< backtrace: #00 pc 0x000000000004e30c /apex/com.android.runtime/lib64/bionic/libc.so (abort+164) #01 pc 0x000000000055f660 /apex/com.android.art/lib64/libart.so (art::Runtime::Abort(char const*)+2308) #02 pc 0x0000000000013978 /system/lib64/libbase.so (android::base::SetAborter(std::__1::function<void (char const*)>&&)::$_3::__invoke(char const*)+76) #03 pc 0x0000000000006e18 /system/lib64/liblog.so (__android_log_assert+336) #04 pc 0x000000000021502c /system/lib64/libhwui.so (android::uirenderer::skiapipeline::SkiaOpenGLPipeline::getFrame()+52) #05 pc 0x000000000021e0e8 /system/lib64/libhwui.so (android::uirenderer::renderthread::CanvasContext::draw()+188) #06 pc 0x0000000000220770 /system/lib64/libhwui.so (_ZNSt3__110__function6__funcIZN7android10uirenderer12renderthread13DrawFrameTask11postAndWaitEvE3$_0NS_9allocatorIS6_EEFvvEEclEv$c303f2d2360db58ed70a2d0ac7ed911b+480) #07 pc 0x000000000020edac /system/lib64/libhwui.so (android::uirenderer::WorkQueue::process()+220) #08 pc 0x00000000002301f8 /system/lib64/libhwui.so (android::uirenderer::renderthread::RenderThread::threadLoop()+88) #09 pc 0x00000000000154d0 /system/lib64/libutils.so (android::Thread::_threadLoop(void*)+260) #10 pc 0x0000000000014d94 /system/lib64/libutils.so (thread_data_t::trampoline(thread_data_t const*)+412) #11 pc 0x00000000000afc6c /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+64) #12 pc 0x00000000000502c8 /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64)
https://github.com/a1017480401/crash_demo/blob/main/android/app/src/main/kotlin/com/example/crash_demo/MainActivity.kt#L11-L13 try this,for me this is useful
I'm experiencing the same crashes on Flutter 3.10.1. I've attached a screenshot of the error message and the stack trace below:
Stack trace: Thread
drawRenderNode called on a context with no surface!
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
pid: 0, tid: 840 >>> com.freresmensah.imagesearch <<<
backtrace:
#00 pc 0x000000000008cd50 /apex/com.android.runtime/lib64/bionic/libc.so (abort+164)
#01 pc 0x000000000053210c /apex/com.android.art/lib64/libart.so (art::Runtime::Abort(char const*)+2340)
#02 pc 0x000000000001394c /system/lib64/libbase.so (android::base::SetAborter(std::__1::function<void (char const*)>&&)::$_3::__invoke(char const*)+76)
#03 pc 0x0000000000006d28 /system/lib64/liblog.so (__android_log_assert+336)
#04 pc 0x000000000021a32c /system/lib64/libhwui.so (android::uirenderer::skiapipeline::SkiaOpenGLPipeline::getFrame()+52)
#05 pc 0x0000000000222ca0 /system/lib64/libhwui.so (android::uirenderer::renderthread::CanvasContext::draw()+404)
#06 pc 0x00000000002251a4 /system/lib64/libhwui.so (_ZNSt3__110__function6__funcIZN7android10uirenderer12renderthread13DrawFrameTask11postAndWaitEvE3$_0NS_9allocatorIS6_EEFvvEEclEv$c303f2d2360db58ed70a2d0ac7ed911b+524)
#07 pc 0x0000000000213874 /system/lib64/libhwui.so (android::uirenderer::WorkQueue::process()+208)
#08 pc 0x000000000023585c /system/lib64/libhwui.so (android::uirenderer::renderthread::RenderThread::threadLoop()+88)
#09 pc 0x0000000000015540 /system/lib64/libutils.so (android::Thread::_threadLoop(void*)+320)
#10 pc 0x0000000000014db4 /system/lib64/libutils.so (thread_data_t::trampoline(thread_data_t const*)+408)
#11 pc 0x00000000000f450c /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+64)
#12 pc 0x000000000008ef34 /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64)
I'm unable to reproduce the issue, but I've noticed that every time a webview instance is called (such as when Google Ads is loaded and displayed or when I open an in-app webpage), this message appears in the console in debug mode on real device:
W/ACodec ( 1334): [OMX.MTK.VIDEO.DECODER.AVC] setting nBufferCountActual to 13 failed: -22
E/libc ( 1334): Access denied finding property "vendor.debug.bq.dump"
I'm not sure if this is related to the issue.
I also encountered this problem. When I use flutter_webivew, I retreat to the background, and then use other apps until the memory of the Android system is tight. At this time, when I reopen flutter_webivew to the foreground, it will crash.
Abort message: 'drawRenderNode called on a context with no surface!' x0 0000000000000000 x1 0000000000007869 x2 0000000000000006 x3 00000077a98f2420 x4 feff71647164636d x5 feff71647164636d x6 feff71647164636d x7 7f7f7f7f7f7f7f7f x8 00000000000000f0 x9 00000078959b9520 x10 0000000000000000 x11 0000000000000001 x12 0000000000000018 x13 ffffffffffffffff x14 0000000000000004 x15 ffffffffffffffff x16 0000007895a868c8 x17 0000007895a63ce0 x18 000000779e456000 x19 00000000000077c5 x20 0000000000007869 x21 00000000ffffffff x22 0000007774f20128 x23 00000077a98f3018 x24 000000789661f098 x25 000000789661c028 x26 0000000000000001 x27 0000007774f20240 x28 00000077a98f3018 x29 00000077a98f24c0 sp 00000077a98f2400 lr 0000007895a17c00 pc 0000007895a17c30
backtrace:
#01 pc 0000000000008a00 /system/lib64/liblog.so (__android_log_assert+324) (BuildId: f602e34dd90ed1ac8367e17bd391f4cf)
#02 pc 00000000003beddc /system/lib64/libhwui.so (android::uirenderer::skiapipeline::SkiaOpenGLPipeline::getFrame()+48) (BuildId: f617615332e02315e20999f8c5b1b25f)
#03 pc 00000000003c87a4 /system/lib64/libhwui.so (android::uirenderer::renderthread::CanvasContext::draw()+176) (BuildId: f617615332e02315e20999f8c5b1b25f)
#04 pc 00000000003c79a4 /system/lib64/libhwui.so (_ZNSt3__110__function6__funcIZN7android10uirenderer12renderthread13DrawFrameTask11postAndWaitEvE3$_0NS_9allocatorIS6_EEFvvEEclEv$c303f2d2360db58ed70a2d0ac7ed911b+216) (BuildId: f617615332e02315e20999f8c5b1b25f)
#05 pc 00000000003da7fc /system/lib64/libhwui.so (android::uirenderer::WorkQueue::process()+228) (BuildId: f617615332e02315e20999f8c5b1b25f)
#06 pc 00000000003da530 /system/lib64/libhwui.so (android::uirenderer::renderthread::RenderThread::threadLoop()+80) (BuildId: f617615332e02315e20999f8c5b1b25f)
#07 pc 00000000000135b0 /system/lib64/libutils.so (android::Thread::_threadLoop(void*)+288) (BuildId: 3bbc3483603a593c41a9af78d8812c9d)
#08 pc 00000000000e2ce8 /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+36) (BuildId: f5ba4e7e3cee771446d26d581339d879)
#09 pc 0000000000084dac /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64) (BuildId: f5ba4e7e3cee771446d26d581339d879)
I have the same problem, how can I solve it?
libc.so] abort
SIGABRT
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
pid: 0, tid: 9786 >>> com.bsavasy.textrec <<<
backtrace:
#00 pc 0x000000000004e178 /apex/com.android.runtime/lib64/bionic/libc.so (abort+168)
#01 pc 0x0000000000552798 /apex/com.android.art/lib64/libart.so (art::Runtime::Abort(char const*)+2260)
#02 pc 0x0000000000013990 /system/lib64/libbase.so (android::base::SetAborter(std::__1::function<void (char const*)>&&)::$_3::__invoke(char const*)+76)
#03 pc 0x0000000000006e58 /system/lib64/liblog.so (__android_log_assert+336)
#04 pc 0x00000000002153bc /system/lib64/libhwui.so (android::uirenderer::skiapipeline::SkiaOpenGLPipeline::getFrame()+52)
#05 pc 0x000000000021e30c /system/lib64/libhwui.so (android::uirenderer::renderthread::CanvasContext::draw()+404)
#06 pc 0x000000000022091c /system/lib64/libhwui.so (_ZNSt3__110__function6__funcIZN7android10uirenderer12renderthread13DrawFrameTask11postAndWaitEvE3$_0NS_9allocatorIS6_EEFvvEEclEv$c303f2d2360db58ed70a2d0ac7ed911b+496)
#07 pc 0x000000000020f140 /system/lib64/libhwui.so (android::uirenderer::WorkQueue::process()+220)
#08 pc 0x0000000000230144 /system/lib64/libhwui.so (android::uirenderer::renderthread::RenderThread::threadLoop()+88)
#09 pc 0x0000000000015414 /system/lib64/libutils.so (android::Thread::_threadLoop(void*)+260)
#10 pc 0x0000000000014cd8 /system/lib64/libutils.so (thread_data_t::trampoline(thread_data_t const*)+412)
#11 pc 0x00000000000af97c /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+64)
#12 pc 0x00000000000500d0 /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64)
I think the problem is that : the android web view package on the users' devices is outdated, I think the problem will be fixed if the user updates the android web view via google play.
I think the problem is that : the android web view package on the users' devices is outdated, I think the problem will be fixed if the user updates the android web view via google play.
The actual reason is that the Activity was terminated due to insufficient memory, but the SurfaceView used by the PlatformView was not reset. As a result, when the Activity is recreated, it attempts to use the old SurfaceView which has already been garbage collected, leading to a null pointer exception. So, in situations where savedInstanceState is not null, I manually performed a cleanup to deallocate resources. like https://github.com/a1017480401/crash_demo/blob/main/android/app/src/main/kotlin/com/example/crash_demo/MainActivity.kt#L11-L13
What exactly am I supposed to do now?
Do I need to paste this in its entirety into my mainactivity file?
package com.example.crash_demo
import android.content.Context
import android.os.Bundle
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
class MainActivity : FlutterActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// if (savedInstanceState != null) {
// MyApplication.flutterEngine.renderer.onTrimMemory(TRIM_MEMORY_COMPLETE)
// }
}
override fun provideFlutterEngine(context: Context): FlutterEngine? {
return MyApplication.flutterEngine
}
}
It's mine activty. I dont understand ?
package com.bsavasy.textrec
import io.flutter.embedding.android.FlutterActivity
class MainActivity: FlutterActivity() {
}
It's mine activty. I dont understand ?
package com.bsavasy.textrec import io.flutter.embedding.android.FlutterActivity class MainActivity: FlutterActivity() { }
override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) if (savedInstanceState != null) { flutterEngine?.renderer?.onTrimMemory(TRIM_MEMORY_COMPLETE) } }
is it ?
import io.flutter.embedding.android.FlutterActivity
class MainActivity: FlutterActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
if (savedInstanceState != null) {
flutterEngine?.renderer?.onTrimMemory(TRIM_MEMORY_COMPLETE)
}
}}
is it ?
import io.flutter.embedding.android.FlutterActivity class MainActivity: FlutterActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) if (savedInstanceState != null) { flutterEngine?.renderer?.onTrimMemory(TRIM_MEMORY_COMPLETE) } }}
import android.os.Bundle import io.flutter.embedding.android.FlutterActivity
class MainActivity : FlutterActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) if (savedInstanceState != null) { flutterEngine?.renderer?.onTrimMemory(TRIM_MEMORY_COMPLETE) } } }
@batuhansavas-yilmaz Certainly, I cannot guarantee its effectiveness for you. It's essential to ensure that your app undergoes thorough testing to verify that the existing flow works flawlessly before proceeding with this solution.
Just out of curiosity, what does this code do in its entirety?
import android.content.Context
import android.os.Bundle
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
class MainActivity : FlutterActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// if (savedInstanceState != null) {
// MyApplication.flutterEngine.renderer.onTrimMemory(TRIM_MEMORY_COMPLETE)
// }
}
override fun provideFlutterEngine(context: Context): FlutterEngine? {
return MyApplication.flutterEngine
}
}
When the Activity is recreate, simulate a low memory situation to trigger Flutter to deallocate Platform-related objects. This should be thoroughly tested, especially for orientation changes, to ensure proper functionality.
How can I test it?
Please test the functionality of your application when switching between portrait and landscape orientations on the WebView interface to ensure it functions correctly.
my application only in vertical directional use
If you were an Android developer, you could consider the following situations that could lead to Activity recreation.
I'am little little developer for flutter 🤗
I'am little little developer for flutter 🤗
I don't recommend you to use my method because it carries certain risks.
I think the problem is that : the android web view package on the users' devices is outdated, I think the problem will be fixed if the user updates the android web view via google play.
The actual reason is that the Activity was terminated due to insufficient memory, but the SurfaceView used by the PlatformView was not reset. As a result, when the Activity is recreated, it attempts to use the old SurfaceView which has already been garbage collected, leading to a null pointer exception. So, in situations where savedInstanceState is not null, I manually performed a cleanup to deallocate resources. like https://github.com/a1017480401/crash_demo/blob/main/android/app/src/main/kotlin/com/example/crash_demo/MainActivity.kt#L11-L13
@chinmaygarde Hello, Chinmaygarde. Would you be available to reassess this issue? This is just my personal analysis, more and more people are encountering this issue.
Yes @chinmaygarde, please
I'am little little developer for flutter 🤗
I don't recommend you to use my method because it carries certain risks.
What risks does it carry?
This is already the one that crashes the most in my app.
I'am little little developer for flutter 🤗
I don't recommend you to use my method because it carries certain risks.
What risks?
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
pid: 0, tid: 27553
backtrace:
#00 pc 0x000000000008cd50 /apex/com.android.runtime/lib64/bionic/libc.so (abort+164)
#01 pc 0x000000000053210c /apex/com.android.art/lib64/libart.so (art::Runtime::Abort(char const*)+2340)
#02 pc 0x000000000001394c /system/lib64/libbase.so (android::base::SetAborter(std::__1::function<void (char const*)>&&)::$_3::__invoke(char const*)+76)
#03 pc 0x0000000000006d28 /system/lib64/liblog.so (__android_log_assert+336)
#04 pc 0x000000000021a32c /system/lib64/libhwui.so (android::uirenderer::skiapipeline::SkiaOpenGLPipeline::getFrame()+52)
#05 pc 0x0000000000222ca0 /system/lib64/libhwui.so (android::uirenderer::renderthread::CanvasContext::draw()+404)
#06 pc 0x00000000002251a4 /system/lib64/libhwui.so (_ZNSt3__110__function6__funcIZN7android10uirenderer12renderthread13DrawFrameTask11postAndWaitEvE3$_0NS_9allocatorIS6_EEFvvEEclEv$c303f2d2360db58ed70a2d0ac7ed911b+524)
#07 pc 0x0000000000213874 /system/lib64/libhwui.so (android::uirenderer::WorkQueue::process()+208)
#08 pc 0x000000000023585c /system/lib64/libhwui.so (android::uirenderer::renderthread::RenderThread::threadLoop()+88)
#09 pc 0x0000000000015540 /system/lib64/libutils.so (android::Thread::_threadLoop(void*)+320)
#10 pc 0x0000000000014db4 /system/lib64/libutils.so (thread_data_t::trampoline(thread_data_t const*)+408)
#11 pc 0x00000000000f450c /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+64)
#12 pc 0x000000000008ef34 /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64)
Any news for this? I rewrite my whole app from unity to flutter because its more light, responsive, and under the hood support android but this ANR crash rate just unbearable. in Unity crash rate just 1-5 affected user/month but flutter just like 20-50 affected user/month.
Same here. this is one of the most frequently crashes reported by play console for my app
Hi! I'm having the same issue on certain devices like Samsung A03 Core and Motorola e22i.
A solution was implemented for this issue, but could it be possible that these manufacturers modified the OS to clean the Surface at a lower memory trim level?
The first fix in Flutter was if (level == 80) recreate surface
. Maybe that value is lower in these devices.
Hi! We test an example project on the Samsung A03 Core (SM-A032M) with Android 12. As you can see in the video we can reproduce the crash when the memory alert is 60, while in the Flutter code there's a hardcoded 80 added to fix this same issue on most devices (previous comment).
adb shell am send-trim-memory com.example.platform_view_crash 60
Example video
https://github.com/flutter/flutter/assets/2294911/7d92ea69-f09f-473c-9314-636e2c9bd30c
Code Sample in this repo
Hi! We test an example project on the Samsung A03 Core (SM-A032M) with Android 12. As you can see in the video we can reproduce the crash when the memory alert is 60, while in the Flutter code there's a hardcoded 80 added to fix this same issue on most devices (previous comment).
Steps to reproduce
- Run the example project on the affected device
- Send application to background
- Trigger the memory alert with
adb shell am send-trim-memory com.example.platform_view_crash 60
- Open the app again and it will crash
Example video
Screen.Recording.2024-03-20.at.12.02.36.mp4 Code Sample in this repo
Flutter doctor Crash log
Hi @pablorengo! Very interesting! the galaxy A03 Core is the device that presents this crash the most in my reports. What would be a possible solution?
Hi @Gilianp! The right solution would be a fix in Flutter code. What we are going to do on our side to workaround this is catch every onTrimMemory
event from Android and convert the level from 60 to 80, only for the devices affected.
Thanks for the reply @pablorengo ! I'll try this workaround and see how it goes in production. Then I will bring the results of the reports here. Thanks again, and I hope the flutter team sees your reproducible example!
Hi @Hixie @exaby73 @pablorengo has provided a more intuitive way to reproduce the issue, hoping to further follow up on this problem~
Hi @Gilianp! The right solution would be a fix in Flutter code. What we are going to do on our side to workaround this is catch every
onTrimMemory
event from Android and convert the level from 60 to 80, only for the devices affected.
It is Happening here also in lots of devices, really easy to simulate having one ad in the screen and sending the command.
To avoid in the meantime you can put this in your MainActivity.kt:
private fun isDeviceAffected(): Boolean {
return Build.MODEL in listOf("SM-A032M", "ModelB", "ModelC")
}
override fun onTrimMemory(level: Int) {
super.onTrimMemory(if (level == 60 && isDeviceAffected()) TRIM_MEMORY_COMPLETE else level);
}
Take in consideration that we are removing level 60 from being sent to the app. It COULD have some unexpected behaviours in devices that are not happening the crash.
IMO it should be done in the engine level like it was done with level 80
Hi @atrope , Thank you very much for the code. I will use it until there is an official solution!!
Hi! This was the impact on crashes after implementing the workaround on moto e22i and Samsung A03 Core.
We have more devices with this error on Crashlytics. We will be adding them to this solution even though they don't appear on Play Console.
Hi! This was the impact on crashes after implementing the workaround on moto e22i and Samsung A03 Core.
We have more devices with this error on Crashlytics. We will be adding them to this solution even though they don't appear on Play Console.
Hi @pablorengo, very good! I am now implementing this solution. Thank you for posting your result here! I put this devices:
[ //Galaxy a03 core
"SM-A032M", "SM-A032F",
//Moto e22i
"moto e22i",
//Redmi ice
"220733SG", "220733SI",
//Honor HONOR X5
"VNA-LX2", "VNA-LX3"]
Hi @Gilianp, bad news from my side. This workaround was implemented with Flutter 3.7.12. After upgrading to 3.19.3, the issue started occurring again, but only for SM-A032M. Additionally, two new devices are impacted: moto g13 and moto g23. I will investigate further.
Hi @Gilianp, bad news from my side. This workaround was implemented with Flutter 3.7.12. After upgrading to 3.19.3, the issue started occurring again, but only for SM-A032M. Additionally, two new devices are impacted: moto g13 and moto g23. I will investigate further.
HI @pablorengo , thank you very much for the information. I just want to double check does the temp workaround still work in 3.19.3+ ? I got the same issue, it seems that the issue also affect all Vivo devices running Funtouch OS 13. I am planning to implement the workaround you suggested if that's still a valid solution.
Scene
1) Custom FlutterEngine instance created by the developer is used in FlutterActivity 2) Flutter UI uses PlatformView
Steps to Reproduce
1) Open developer mode, Turn on the 'Don't keep activities' option 2) Open the app, Press the button to jump to FlutterActivity page 3) Turn the app to the background, open another app (several apps are better ) 4) Turn the app to foreground and the app will crash
Code sample
Demo Url: https://github.com/a1017480401/crash_demo.gitLogs
Crash Log : https://github.com/a1017480401/crash_demo/blob/main/crash_log ``` [√] Flutter (Channel stable, 3.3.2, on Microsoft Windows [版本 10.0.19044.2006], locale zh-CN) • Flutter version 3.3.2 on channel stable at D:\code\flutter\SDK\flutter_windows_3.3.0-stable\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision e3c29ec00c (9 days ago), 2022-09-14 08:46:55 -0500 • Engine revision a4ff2c53d8 • Dart version 2.18.1 • DevTools version 2.15.0 • Pub download mirror https://pub.flutter-io.cn • Flutter download mirror https://storage.flutter-io.cn [√] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1) • Android SDK at D:\code\android\AndroidSDK • Platform android-33, build-tools 32.1.0-rc1 • Java binary at: D:\code\android\AS\jre\bin\java • Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840) • All Android licenses accepted. [√] Chrome - develop for the web • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe [√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.1.6) • Visual Studio at D:\tools\Visual Studio\2022\Components • Visual Studio Community 2022 version 17.1.32421.90 • Windows 10 SDK version 10.0.19041.0 [√] Android Studio (version 2021.2) • Android Studio at D:\code\android\AS • 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.12+7-b1504.28-7817840) [√] Connected device (5 available) • V2055A (mobile) • 343470231100DGT • android-arm64 • Android 11 (API 30) • sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64 • Android 12 (API 31) (emulator) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [版本 10.0.19044.2006] • Chrome (web) • chrome • web-javascript • Google Chrome 105.0.5195.127 • Edge (web) • edge • web-javascript • Microsoft Edge 105.0.1343.27 [√] HTTP Host Availability • All required HTTP hosts are available • No issues found! ``` ```