compose-multiplatform: Crash on iOS: `GrGpuResource::release()`
Describe the bug We’ve received a handful of reports of crashes on iOS via the AppStore & Firebase Crashlytics. We have not yet been able to reproduce the crash ourselves.
Affected platforms Select one of the platforms below:
- iOS
Versions
- Kotlin version*: 1.9.20-RC
- Compose Multiplatform version*: 1.5.10-rc01
- OS version(s)* (required for Desktop and iOS issues): iOS 16.6.1 ~ 17.0.3
- OS architecture (x86 or arm64): arm64
To Reproduce We don’t have reproduction steps as of yet. We’ve seen a half-dozen of reports via the AppStore & Firebase Crashlytics.
Expected behavior The app should not crash.
Screenshots N/A
Additional context
Crashed: RenderingDispatchQueue
0 Preat 0x10c3e80 GrGpuResource::release() + 2324312
1 Preat 0x10d070c GrResourceCache::purgeAsNeeded() + 2375652
2 Preat 0x10d070c GrResourceCache::purgeAsNeeded() + 2375652
3 Preat 0x10d097c GrResourceCache::insertResource(GrGpuResource*) + 2376276
4 Preat 0x1173b04 GrMtlBuffer::GrMtlBuffer(GrMtlGpu*, unsigned long, GrGpuBufferType, GrAccessPattern, std::__1::basic_string_view<char, std::__1::char_traits<char>>) + 3044316
5 Preat 0x1173a10 GrMtlBuffer::Make(GrMtlGpu*, unsigned long, GrGpuBufferType, GrAccessPattern) + 3044072
6 Preat 0x10c29dc GrGpu::createBuffer(unsigned long, GrGpuBufferType, GrAccessPattern) + 2319028
7 Preat 0x10d57f4 GrResourceProvider::createBuffer(unsigned long, GrGpuBufferType, GrAccessPattern, GrResourceProvider::ZeroInit) + 2396364
8 Preat 0x10d6b48 GrStagingBufferManager::allocateStagingBufferSlice(unsigned long, unsigned long) + 2401312
9 Preat 0x1179810 GrMtlGpu::uploadToTexture(GrMtlTexture*, SkIRect, GrColorType, GrMipLevel const*, int) + 3068136
10 Preat 0x10c2604 GrGpu::writePixels(GrSurface*, SkIRect, GrColorType, GrColorType, GrMipLevel const*, int, bool) + 2318044
11 Preat 0x10c2118 GrGpu::createTexture(SkISize, GrBackendFormat const&, GrTextureType, GrRenderable, int, SkBudgeted, GrProtected, GrColorType, GrColorType, GrMipLevel const*, int, std::__1::basic_string_view<char, std::__1::char_traits<char>>) + 2316784
12 Preat 0x10d4650 GrResourceProvider::createTexture(SkISize, GrBackendFormat const&, GrTextureType, GrColorType, GrRenderable, int, SkBudgeted, GrMipmapped, GrProtected, GrMipLevel const*, std::__1::basic_string_view<char, std::__1::char_traits<char>>) + 2391848
13 Preat 0x10d4ef0 GrResourceProvider::createTexture(SkISize, GrBackendFormat const&, GrTextureType, GrColorType, GrRenderable, int, SkBudgeted, SkBackingFit, GrProtected, GrMipLevel const&, std::__1::basic_string_view<char, std::__1::char_traits<char>>) + 2394056
14 Preat 0x10ca5dc std::__1::__function::__func<GrProxyProvider::createNonMippedProxyFromBitmap(SkBitmap const&, SkBackingFit, SkBudgeted)::$_0, std::__1::allocator<GrProxyProvider::createNonMippedProxyFromBitmap(SkBitmap const&, SkBackingFit, SkBudgeted)::$_0>, GrSurfaceProxy::LazyCallbackResult (GrResourceProvider*, GrSurfaceProxy::LazySurfaceDesc const&)>::operator()(GrResourceProvider*&&, GrSurfaceProxy::LazySurfaceDesc const&) + 2350772
15 Preat 0x10d8680 GrSurfaceProxyPriv::doLazyInstantiation(GrResourceProvider*) + 2408280
16 Preat 0x10c923c GrProxyProvider::createProxyFromBitmap(SkBitmap const&, GrMipmapped, SkBackingFit, SkBudgeted) + 2345748
17 Preat 0x10e12c4 make_bmp_proxy(GrProxyProvider*, SkBitmap const&, GrColorType, GrMipmapped, SkBackingFit, SkBudgeted) + 2444188
18 Preat 0x10e0f24 GrMakeCachedBitmapProxyView(GrRecordingContext*, SkBitmap const&, std::__1::basic_string_view<char, std::__1::char_traits<char>>, GrMipmapped) + 2443260
19 Preat 0xfa5ccc SkImage_Raster::onAsFragmentProcessor(GrRecordingContext*, SkSamplingOptions, SkTileMode const*, SkMatrix const&, SkRect const*, SkRect const*) const + 1152420
20 Preat 0xfa1ba4 SkImage_Base::asFragmentProcessor(GrRecordingContext*, SkSamplingOptions, SkTileMode const*, SkMatrix const&, SkRect const*, SkRect const*) const + 1135740
21 Preat 0x10a3db4 (anonymous namespace)::draw_image(GrRecordingContext*, skgpu::v1::SurfaceDrawContext*, GrClip const*, SkMatrixProvider const&, SkPaint const&, SkImage_Base const&, SkRect const&, SkRect const&, SkPoint const*, SkMatrix const&, GrQuadAAFlags, SkCanvas::SrcRectConstraint, SkSamplingOptions, SkTileMode) + 2193036
22 Preat 0x10a580c skgpu::v1::Device::drawImageQuad(SkImage const*, SkRect const*, SkRect const*, SkPoint const*, GrQuadAAFlags, SkMatrix const*, SkSamplingOptions const&, SkPaint const&, SkCanvas::SrcRectConstraint) + 2199780
23 Preat 0x10a1a00 skgpu::v1::Device::drawImageRect(SkImage const*, SkRect const*, SkRect const&, SkSamplingOptions const&, SkPaint const&, SkCanvas::SrcRectConstraint) + 2183896
24 Preat 0xee25b0 SkCanvas::onDrawImageRect2(SkImage const*, SkRect const&, SkRect const&, SkSamplingOptions const&, SkPaint const*, SkCanvas::SrcRectConstraint) + 351880
25 Preat 0xf55020 SkRecordDraw(SkRecord const&, SkCanvas*, SkPicture const* const*, SkDrawable* const*, int, SkBBoxHierarchy const*, SkPicture::AbortCallback*) + 821496
26 Preat 0xee40a0 SkCanvas::onDrawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 358776
27 Preat 0xee3f98 SkCanvas::drawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 358512
28 Preat 0xf55020 SkRecordDraw(SkRecord const&, SkCanvas*, SkPicture const* const*, SkDrawable* const*, int, SkBBoxHierarchy const*, SkPicture::AbortCallback*) + 821496
29 Preat 0xee40a0 SkCanvas::onDrawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 358776
30 Preat 0xee3f98 SkCanvas::drawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 358512
31 Preat 0xf55020 SkRecordDraw(SkRecord const&, SkCanvas*, SkPicture const* const*, SkDrawable* const*, int, SkBBoxHierarchy const*, SkPicture::AbortCallback*) + 821496
32 Preat 0xee40a0 SkCanvas::onDrawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 358776
33 Preat 0xee3f98 SkCanvas::drawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 358512
34 Preat 0xf55020 SkRecordDraw(SkRecord const&, SkCanvas*, SkPicture const* const*, SkDrawable* const*, int, SkBBoxHierarchy const*, SkPicture::AbortCallback*) + 821496
35 Preat 0xee40a0 SkCanvas::onDrawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 358776
36 Preat 0xee3f98 SkCanvas::drawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 358512
37 Preat 0xf55020 SkRecordDraw(SkRecord const&, SkCanvas*, SkPicture const* const*, SkDrawable* const*, int, SkBBoxHierarchy const*, SkPicture::AbortCallback*) + 821496
38 Preat 0xee40a0 SkCanvas::onDrawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 358776
39 Preat 0xee3f98 SkCanvas::drawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 358512
40 Preat 0xf55020 SkRecordDraw(SkRecord const&, SkCanvas*, SkPicture const* const*, SkDrawable* const*, int, SkBBoxHierarchy const*, SkPicture::AbortCallback*) + 821496
41 Preat 0xee40a0 SkCanvas::onDrawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 358776
42 Preat 0xee3f98 SkCanvas::drawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 358512
43 Preat 0xf55020 SkRecordDraw(SkRecord const&, SkCanvas*, SkPicture const* const*, SkDrawable* const*, int, SkBBoxHierarchy const*, SkPicture::AbortCallback*) + 821496
44 Preat 0xee40a0 SkCanvas::onDrawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 358776
45 Preat 0xee3f98 SkCanvas::drawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 358512
46 Preat 0xf55020 SkRecordDraw(SkRecord const&, SkCanvas*, SkPicture const* const*, SkDrawable* const*, int, SkBBoxHierarchy const*, SkPicture::AbortCallback*) + 821496
47 Preat 0xee40a0 SkCanvas::onDrawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 358776
48 Preat 0xee3f98 SkCanvas::drawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 358512
49 Preat 0x13f614c org_jetbrains_skia_Canvas__1nDrawPicture + 5675556
50 Preat 0x3734e8 kfun:org.jetbrains.skia.Canvas#drawPicture(org.jetbrains.skia.Picture;org.jetbrains.skia.Matrix33?;org.jetbrains.skia.Paint?){}org.jetbrains.skia.Canvas + 62 (Native.native.kt:62)
51 Preat 0x4cf82c kfun:androidx.compose.ui.window.MetalRedrawer.$draw$lambda$4$FUNCTION_REFERENCE$4.invoke#internal + 579 (Canvas.kt:579)
52 Preat 0x4d0d4c kfun:androidx.compose.ui.window.MetalRedrawer.$draw$lambda$4$FUNCTION_REFERENCE$4.$<bridge-UNN>invoke(){}#internal + 428 (MetalRedrawer.kt:428)
53 Preat 0xa37ce0 kfun:kotlin.Function0#invoke(){}1:0-trampoline + 1 ([K][Suspend]Functions:1)
54 Preat 0x4d0e0c kfun:androidx.compose.ui.window.MetalRedrawer.$draw$lambda$5$FUNCTION_REFERENCE$5.$<bridge-UNN>invoke(){}#internal + 15 (ObjectiveCUtils.kt:15)
55 Preat 0xa37ce0 kfun:kotlin.Function0#invoke(){}1:0-trampoline + 1 ([K][Suspend]Functions:1)
56 Preat 0xe5df48 ___6f72672e6a6574627261696e732e636f6d706f73652e75693a75692f6f70742f6275696c644167656e742f776f726b2f356234626566333562333562396631322f636f6d706f73652f75692f75692f7372632f75696b69744d61696e2f6b6f746c696e2f616e64726f6964782f636f6d706f73652f75692f77696e646f772f4d6574616c52656472617765722e6b74_knbridge114_block_invoke + 4384530248
57 libdispatch.dylib 0x2320 _dispatch_call_block_and_release + 32
58 libdispatch.dylib 0x3eac _dispatch_client_callout + 20
59 libdispatch.dylib 0xb534 _dispatch_lane_serial_drain + 668
60 libdispatch.dylib 0xc0a4 _dispatch_lane_invoke + 384
61 libdispatch.dylib 0x16cdc _dispatch_workloop_worker_thread + 648
62 libsystem_pthread.dylib 0xddc _pthread_wqthread + 288
63 libsystem_pthread.dylib 0xb7c start_wqthread + 8
About this issue
- Original URL
- State: closed
- Created 8 months ago
- Comments: 71 (24 by maintainers)
Commits related to this issue
- Make Skia context usage a critical section on iOS. (#896) ## Proposed Changes Since there are no reliable repros, it's a speculative fix for [the crash](https://github.com/JetBrains/compose-multi... — committed to JetBrains/compose-multiplatform-core by elijah-semyonov 8 months ago
- Disable encoding on separate thread for iOS (#907) ## Proposed Changes Using Skia context in multiple threads simultaneously leads to occasional unreproducable crashes on users' side. Roll back ... — committed to JetBrains/compose-multiplatform-core by elijah-semyonov 7 months ago
- Disable encoding on separate thread for iOS (#907) ## Proposed Changes Using Skia context in multiple threads simultaneously leads to occasional unreproducable crashes on users' side. Roll back ... — committed to JetBrains/compose-multiplatform-core by elijah-semyonov 7 months ago
- Make Skia context usage a critical section on iOS. (#896) ## Proposed Changes Since there are no reliable repros, it's a speculative fix for [the crash](https://github.com/JetBrains/compose-multi... — committed to JetBrains/compose-multiplatform-core by elijah-semyonov 8 months ago
- Disable encoding on separate thread for iOS (#907) ## Proposed Changes Using Skia context in multiple threads simultaneously leads to occasional unreproducable crashes on users' side. Roll back ... — committed to JetBrains/compose-multiplatform-core by elijah-semyonov 7 months ago
@dima-avdeev-jb Thanks so much for the help. We launched on Production with CMP today. You and your team have done some awesome work. Eagerly waiting for 1.5.11.
@dima-avdeev-jb @elijah-semyonov @pjBooms This works. Have added the boolean. Testing it with this. Till now have not seen a crash. Previous crash scenarios seem to be holding stable. Sounds encouraging but we will give it some more time.
@pjBooms @elijah-semyonov The crash is still there with
0.0.0-dev1270
and withoutforceMainThreadRendering
Stacktrace@LaatonWalaBhoot Thanks so much for good assist in problem solving!
Yeah, for now you can use Compose
0.0.0-dev1260
and forceMainThreadRendering = true with custom Skiko version as well.I am sure, that Compose
1.5.11
will contains fix with fonts. I hope fix forCrashed: RenderingDispatchQueue
as well.As for white backgroud - not sure here. First of all we want to fix and publish as fast as possible all critical bugs. White background may be fixed later… I don’t know yet.
Could be related to either skia upgrade or separate thread render commands encoding. Hard to figure out without reliable repro, I will have a closer look at it.
@elijah-semyonov Please spare me some time. In the middle of the prod release. Will update you at the earliest
@dima-avdeev-jb Font crash and lag are no longer happening with the new skiko version. That seems to be fixed. However
Crashed: RenderingDispatchQueue
is still there with1.5.10
and0.0.0-dev1260
For now moving to production with0.0.0-dev1260
andforceMainThreadRendering = true
Hope this gets resolved in 1.5.11. Would UIKitView white background also get addressed in 1.5.11?Stacktrace:
@LaatonWalaBhoot It is good to test with Compose version
1.5.10
and with0.0.0-dev1260
as well. It will help us to better understand the problem.Anyway, we want to fix all of it in next Compose
1.5.11
release@dima-avdeev-jb Please give me some time to confirm this. Would this also mean I do not have to use the 0.0.0-dev1260 build and can fallback to 1.5.10? If
Crashed: RenderingDispatchQueue
crash still appears with Skiko 0.7.88, Do I have to use 0.0.0-dev1260 for the time being?We fixed Crash with fonts. Please take a look at this comment in another Issue: https://github.com/JetBrains/compose-multiplatform/issues/3822#issuecomment-1806367451
Can you please check it without usage of flag
forceMainThreadRendering
at first. We hope, that new version of Skiko will help with this Crash as well.But, if crash
Crashed: RenderingDispatchQueue
will still appears, you can useforceMainThreadRendering
That’s what the problem is. I am not sure when it started but it has been there since 1.5.1 I have tried expect/actual and moko but intermittent crashes are what is a dealbreaker App is already in production hence staying with the single font for now because that is the only one working without crashes.
@GuilhE I feel your pain. I tried multiple implementations of expect/actual like how Tivi does it but none worked. Since I am using cocoa pods maybe that’s why. Spent almost a week on this. Attaching my typography code maybe this can help you. I am using MOKO for now until CMP releases font support. As you can see I am using only one flavour. Using multiple was causing lags and crashes.
@dima-avdeev-jb Did try it. Both crashes are still reproduced. 😦 While
GrGpuResource::release()
is rare (seems to be linked to UIKitView implementation of Lottie), Font crash is quite frequent, it might be linked to Moko resources implementation of loading font resources. Changing it to manual font loading might fix it.@dima-avdeev-jb Can’t say this only happens on navigating back It is very very random and quite frequent as well. Sometimes happens on scrolling to the top and also while navigating to a screen.
Some changes that I have tried.
I know you guys have plenty on your plate. But 2 weeks of production users getting affected would be a bit much. Is it possible to make a dev release?
@elijah-semyonov @dima-avdeev-jb Without the boolean flag We are getting this stack trace it is different than the ones we have been seeing before
Edit: This is happening with the boolean flag as well
Yes. Will do a round of A/B with this and report back.
@dima-avdeev-jb Please take a look debug.txt
We see this also, it should related to the pictures