skia4delphi / skia4delphi

Skia4Delphi is a cross-platform 2D graphics API for Delphi platforms based on Google's Skia Graphics Library. It provides a comprehensive 2D API that can be used across mobile, server and desktop models to render images.
https://skia4delphi.org
MIT License
694 stars 141 forks source link

Android crash of app when restored from background on certain devices #225

Closed MyBuzzTechnologies closed 1 year ago

MyBuzzTechnologies commented 1 year ago

Reproduced with Skia4Delphi 5.0.0 Delphi 11.2 Android build (64 bit) of any FMX app on specific devices.

We have a strange issue which is only occurring on certain devices, but we've had over 2000 reports of the crash from various low-end Android devices logged in the Play Store developer console. Higher end devices (such as most modern Samsung or Huawei are working ok).

  1. Create a new Firemonkey app on Delphi 11.2. An empty one is ok.
  2. Right-click the Project node and "Enable Skia" which adds the "GlobalUseSkia:=True" to the project sources.
  3. Run the app on an affected device - it runs ok at first.
  4. Tap the home button to put the app into the background of the phone
  5. Tap the launcher button or the app icon on the Home Screen to pull the app into the foreground.
  6. Within 1-2s the app crashes.
  7. Running the app again works ok as it's a cold open.

If you set GlobalUseSkia:=False (or don't enable Skia for the project) it works perfectly and can be put into the background and restored without any problems. This is definitely related to Skia4Delphi somehow.

We have a wide range of devices which don't demonstrate this problem so may be related to a specific chipset or implementation issue. I've included the details of a device we can produce on 100% to see if it helps, along with the crash logs and SysLog from the device at time time of crash.

Downgrading to Skia4Delphi v4.1.1 resolved this issue so it's a new problem in v5.0.0

If you'd like me to test any potential fixed version I'd be happy to assist so please let me know.

Device: Oppo A16s Model: CPH2271 CPU: Helio G35 OctaCore RAM: 4GB GPU: PowerVR Rogue GE8320 Android: Android 12.1, ColorOS 12.1

Crash Log from LogCat

ViewRootImplExtImpl showSurfaceViewBackground subLayer:-2, name:com.embarcadero.Project1/com.embarcadero.firemonkey.FMXNativeActivity
BufferQueueProducer [SurfaceView[com.embarcadero.Project1/com.embarcadero.firemonkey.FMXNativeActivity]#2(BLAST Consumer)2](id:433c00000002,api:1,p:17212,c:17212) disconnect: api -1
BLASTBufferQueue    BLASTBufferItemConsumer::onDisconnect()
BLASTBufferQueue    [SurfaceView[com.embarcadero.Project1/com.embarcadero.firemonkey.FMXNativeActivity]#2] destructor()
BufferQueueConsumer [SurfaceView[com.embarcadero.Project1/com.embarcadero.firemonkey.FMXNativeActivity]#2(BLAST Consumer)2](id:433c00000002,api:0,p:-1,c:17212) disconnect
BufferQueueProducer [ViewRootImpl[FMXNativeActivity]#0(BLAST Consumer)0](id:433c00000000,api:1,p:17212,c:17212) disconnect: api 1
BLASTBufferQueue    BLASTBufferItemConsumer::onDisconnect()
BLASTBufferQueue    releaseBufferCallbackThunk bufferId:73924977098761 framenumber:3 blastBufferQueue is dead
BLASTBufferQueue    [ViewRootImpl[FMXNativeActivity]#0] destructor()
BufferQueueConsumer [ViewRootImpl[FMXNativeActivity]#0(BLAST Consumer)0](id:433c00000000,api:0,p:-1,c:17212) disconnect
BufferQueueProducer [ViewRootImpl[PopupWindow:4179dea]#3(BLAST Consumer)3](id:433c00000003,api:1,p:17212,c:17212) disconnect: api 1
BLASTBufferQueue    BLASTBufferItemConsumer::onDisconnect()
BLASTBufferQueue    [ViewRootImpl[PopupWindow:4179dea]#3] destructor()
BufferQueueConsumer [ViewRootImpl[PopupWindow:4179dea]#3(BLAST Consumer)3](id:433c00000003,api:0,p:-1,c:17212) disconnect
GED ged_boost_gpu_freq, level 100, eOrigin 2, final_idx 2, oppidx_max 2, oppidx_min 0
BLASTBufferQueue    releaseBufferCallbackThunk bufferId:73924977098755 framenumber:3 blastBufferQueue is dead
BufferQueueConsumer [](id:433c00000004,api:0,p:-1,c:17212) connect: controlledByApp=false
BLASTBufferQueue    [ViewRootImpl[PopupWindow:4179dea]#4] constructor()
BufferQueueProducer [ViewRootImpl[PopupWindow:4179dea]#4(BLAST Consumer)4](id:433c00000004,api:1,p:17212,c:17212) connect: api=1 producerControlledByApp=true
BufferQueueConsumer [](id:433c00000005,api:0,p:-1,c:17212) connect: controlledByApp=false
BLASTBufferQueue    [ViewRootImpl[FMXNativeActivity]#5] constructor()
BufferQueueProducer [ViewRootImpl[FMXNativeActivity]#5(BLAST Consumer)5](id:433c00000005,api:1,p:17212,c:17212) connect: api=1 producerControlledByApp=true
BufferQueueConsumer [](id:433c00000006,api:0,p:-1,c:17212) connect: controlledByApp=false
BLASTBufferQueue    [SurfaceView[com.embarcadero.Project1/com.embarcadero.firemonkey.FMXNativeActivity]#6] constructor()
ViewRootImplExtImpl showSurfaceViewBackground subLayer:-2, name:com.embarcadero.Project1/com.embarcadero.firemonkey.FMXNativeActivity
BufferQueueProducer [SurfaceView[com.embarcadero.Project1/com.embarcadero.firemonkey.FMXNativeActivity]#2(BLAST Consumer)2](id:433c00000002,api:0,p:-1,c:17212) query: BufferQueue has been abandoned
IMGSRV  :2478: WSEGL_GetDrawableParameters: Failed to obtain minimal parameters
IMGSRV  :471: KEGLGetDrawableParameters: Native window is invalid
libEGL  eglMakeCurrentImpl:1062 error 300b (EGL_BAD_NATIVE_WINDOW)
ViewRootImplExtImpl showSurfaceViewBackground subLayer:-2, name:com.embarcadero.Project1/com.embarcadero.firemonkey.FMXNativeActivity
BufferQueueProducer [](id:433c00000006,api:0,p:-1,c:17212) disconnect: api -1
BLASTBufferQueue    [SurfaceView[com.embarcadero.Project1/com.embarcadero.firemonkey.FMXNativeActivity]#6] destructor()
BufferQueueConsumer [SurfaceView[com.embarcadero.Project1/com.embarcadero.firemonkey.FMXNativeActivity]#6(BLAST Consumer)6](id:433c00000006,api:0,p:-1,c:17212) disconnect

Stack Trace from the app at time of crash

_RaiseAtExcept(TObject*, Pointer) + 64
_RaiseExcept(TObject*) + 24
Skia.Fmx.Canvas.Gl.TGlCanvas.MakeCurrent() + 64
Skia.Fmx.Canvas.Gl.TGlCanvas.DestroyContext() + 40
Skia.Fmx.Canvas.Gl.TGlCanvas.Destroy() + 48
TObject.Free() + 40
Fmx.Types.DisposeOfAndNil(Pointer) + 40
Fmx.Forms.TCustomForm.RecreateCanvas() + 32
Fmx.Forms.TCustomForm.RecreateResources() + 28
Fmx.Platform.Ui.Android.TAndroidWindowHandle.TSurfaceViewListener.surfaceCreated(Androidapi.Jni.Graphicscontentviewtext.JSurfaceHolder) + 136

Rtti.Invoke(Pointer, array of Rtti.TValue, Typinfo.TCallConv, Typinfo.TTypeInfo*, Boolean, Boolean) + 560
Rtti.TRttiInstanceMethodEx.DispatchInvoke(Rtti.TValue, Rtti.TValue const*, Integer) + 1332
Rtti.TRttiMethod.Invoke(TObject*, Rtti.TValue const*, Integer) + 88
Androidapi.Jnibridge.dispatchToNative2(JNINativeInterface**, Androidapi.Jni._JNIObject*, Androidapi.Jni._JNIObject*, Androidapi.Jni._JNIObject*, Androidapi.Jni._JNIObject*, Int64) + 696
maurobotta commented 1 year ago

news ?

abritolda commented 1 year ago

same situation, any news about that

paulocesarbot commented 1 year ago

Fixed on new version 6.0.0-beta1

MyBuzzTechnologies commented 1 year ago

Unfortunately, this is still a problem and hasn't been fixed. I thought it had but was my mistake (the app was still using FMX rather than Skia).

Could you please re-open this and investigate?

paulocesarbot commented 1 year ago

@MyBuzzTechnologies Thank you very much for the feedback! Please, apply the last fix: https://github.com/skia4delphi/skia4delphi/commit/f218d967d7b189f7c52b91eedc5e3b4ff0d07492

MyBuzzTechnologies commented 1 year ago

Thank you, that seems to have worked. Thank you for fixing this so quickly!

paulocesarbot commented 1 year ago

The fix was included on new release: v6.0.0-beta2