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

Crash on iOS: GrGpuResource::release() #3862

Closed
onseok opened this issue Oct 24, 2023 · 71 comments · Fixed by JetBrains/compose-multiplatform-core#896 or JetBrains/compose-multiplatform-core#907
Assignees
Labels
crash ios p:critical Critical priority regression rendering Low level rendering

Comments

@onseok
Copy link

onseok commented Oct 24, 2023

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
@onseok onseok added bug Something isn't working submitted labels Oct 24, 2023
@elijah-semyonov elijah-semyonov added rendering Low level rendering ios regression and removed submitted labels Oct 25, 2023
@elijah-semyonov
Copy link
Contributor

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 elijah-semyonov self-assigned this Oct 25, 2023
@elijah-semyonov elijah-semyonov added crash p:high High priority and removed bug Something isn't working labels Oct 25, 2023
@juhaodong
Copy link

We see this also, it should related to the pictures

@juhaodong
Copy link

I believe this related to the oom issue on bitmaps, only crash on IOS, tried everything to stop the crash.

@juhaodong
Copy link

flutter/flutter#89204

@juhaodong
Copy link

I can provide lots of crash stack trace if that can help

@LaatonWalaBhoot
Copy link

LaatonWalaBhoot commented Nov 4, 2023

Happening to my app which is in production.
Multiple reports of instances crashing after resuming and scrolling the app.
It happened frequently on 17.0.3 and sporadically on 16.6.1.
I have multiple stack traces. One way to reproduce this was resuming the app from the background and fast-scrolling through the feed.
This is a huge blocker for us as it is polluting our dev pipeline.

Crashed: RenderingDispatchQueue
0  Medial                         0x15db094 virtual thunk to GrMtlTexture::onRelease() + 4322209940
1  Medial                         0x14f1b34 GrGpuResource::release() + 4321254196
2  Medial                         0x14fe438 GrResourceCache::purgeAsNeeded() + 4321305656
3  Medial                         0x14fe6a8 GrResourceCache::insertResource(GrGpuResource*) + 4321306280
4  Medial                         0x15da508 GrMtlTexture::GrMtlTexture(GrMtlGpu*, SkBudgeted, SkISize, sk_sp<GrMtlAttachment>, GrMipmapStatus, std::__1::basic_string_view<char, std::__1::char_traits<char>>) + 4322206984
5  Medial                         0x15da8b0 GrMtlTexture::MakeNewTexture(GrMtlGpu*, SkBudgeted, SkISize, MTLPixelFormat, unsigned int, GrMipmapStatus, std::__1::basic_string_view<char, std::__1::char_traits<char>>) + 4322207920
6  Medial                         0x15cc788 GrMtlGpu::onCreateTexture(SkISize, GrBackendFormat const&, GrRenderable, int, SkBudgeted, GrProtected, int, unsigned int, std::__1::basic_string_view<char, std::__1::char_traits<char>>) + 4322150280
7  Medial                         0x14efa9c GrGpu::createTextureCommon(SkISize, GrBackendFormat const&, GrTextureType, GrRenderable, int, SkBudgeted, GrProtected, int, unsigned int, std::__1::basic_string_view<char, std::__1::char_traits<char>>) + 4321245852
8  Medial                         0x14efd14 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>>) + 4321246484
9  Medial                         0x150237c 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>>) + 4321321852
10 Medial                         0x1502c1c 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>>) + 4321324060
11 Medial                         0x14f82c4 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&) + 4321280708
12 Medial                         0x1506588 GrSurfaceProxyPriv::doLazyInstantiation(GrResourceProvider*) + 4321338760
13 Medial                         0x14f6f24 GrProxyProvider::createProxyFromBitmap(SkBitmap const&, GrMipmapped, SkBackingFit, SkBudgeted) + 4321275684
14 Medial                         0x150f1cc make_bmp_proxy(GrProxyProvider*, SkBitmap const&, GrColorType, GrMipmapped, SkBackingFit, SkBudgeted) + 4321374668
15 Medial                         0x150ee2c GrMakeCachedBitmapProxyView(GrRecordingContext*, SkBitmap const&, std::__1::basic_string_view<char, std::__1::char_traits<char>>, GrMipmapped) + 4321373740
16 Medial                         0x14d1d20 (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) + 4321123616
17 Medial                         0x14d2dd0 skgpu::v1::Device::drawImageQuad(SkImage const*, SkRect const*, SkRect const*, SkPoint const*, GrQuadAAFlags, SkMatrix const*, SkSamplingOptions const&, SkPaint const&, SkCanvas::SrcRectConstraint) + 4321127888
18 Medial                         0x14cefc4 skgpu::v1::Device::drawImageRect(SkImage const*, SkRect const*, SkRect const&, SkSamplingOptions const&, SkPaint const&, SkCanvas::SrcRectConstraint) + 4321112004
19 Medial                         0x130a4fc SkCanvas::onDrawImageRect2(SkImage const*, SkRect const&, SkRect const&, SkSamplingOptions const&, SkPaint const*, SkCanvas::SrcRectConstraint) + 4319257852
20 Medial                         0x137f9f0 SkRecordDraw(SkRecord const&, SkCanvas*, SkPicture const* const*, SkDrawable* const*, int, SkBBoxHierarchy const*, SkPicture::AbortCallback*) + 4319738352
21 Medial                         0x130bfec SkCanvas::onDrawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 4319264748
22 Medial                         0x130bee4 SkCanvas::drawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 4319264484
23 Medial                         0x137f9f0 SkRecordDraw(SkRecord const&, SkCanvas*, SkPicture const* const*, SkDrawable* const*, int, SkBBoxHierarchy const*, SkPicture::AbortCallback*) + 4319738352
24 Medial                         0x130bfec SkCanvas::onDrawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 4319264748
25 Medial                         0x130bee4 SkCanvas::drawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 4319264484
26 Medial                         0x137f9f0 SkRecordDraw(SkRecord const&, SkCanvas*, SkPicture const* const*, SkDrawable* const*, int, SkBBoxHierarchy const*, SkPicture::AbortCallback*) + 4319738352
27 Medial                         0x130bfec SkCanvas::onDrawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 4319264748
28 Medial                         0x130bee4 SkCanvas::drawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 4319264484
29 Medial                         0x137f9f0 SkRecordDraw(SkRecord const&, SkCanvas*, SkPicture const* const*, SkDrawable* const*, int, SkBBoxHierarchy const*, SkPicture::AbortCallback*) + 4319738352
30 Medial                         0x130bfec SkCanvas::onDrawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 4319264748
31 Medial                         0x130bee4 SkCanvas::drawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 4319264484
32 Medial                         0x137f9f0 SkRecordDraw(SkRecord const&, SkCanvas*, SkPicture const* const*, SkDrawable* const*, int, SkBBoxHierarchy const*, SkPicture::AbortCallback*) + 4319738352
33 Medial                         0x130bfec SkCanvas::onDrawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 4319264748
34 Medial                         0x130bee4 SkCanvas::drawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 4319264484
35 Medial                         0x137f9f0 SkRecordDraw(SkRecord const&, SkCanvas*, SkPicture const* const*, SkDrawable* const*, int, SkBBoxHierarchy const*, SkPicture::AbortCallback*) + 4319738352
36 Medial                         0x130bfec SkCanvas::onDrawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 4319264748
37 Medial                         0x130bee4 SkCanvas::drawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 4319264484
38 Medial                         0x137f9f0 SkRecordDraw(SkRecord const&, SkCanvas*, SkPicture const* const*, SkDrawable* const*, int, SkBBoxHierarchy const*, SkPicture::AbortCallback*) + 4319738352
39 Medial                         0x130bfec SkCanvas::onDrawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 4319264748
40 Medial                         0x130bee4 SkCanvas::drawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 4319264484
41 Medial                         0x137f9f0 SkRecordDraw(SkRecord const&, SkCanvas*, SkPicture const* const*, SkDrawable* const*, int, SkBBoxHierarchy const*, SkPicture::AbortCallback*) + 4319738352
42 Medial                         0x130bfec SkCanvas::onDrawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 4319264748
43 Medial                         0x130bee4 SkCanvas::drawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 4319264484
44 Medial                         0x137f9f0 SkRecordDraw(SkRecord const&, SkCanvas*, SkPicture const* const*, SkDrawable* const*, int, SkBBoxHierarchy const*, SkPicture::AbortCallback*) + 4319738352
45 Medial                         0x130bfec SkCanvas::onDrawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 4319264748
46 Medial                         0x130bee4 SkCanvas::drawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 4319264484
47 Medial                         0x1857c24 org_jetbrains_skia_Canvas__1nDrawPicture + 4324817956
48 Medial                         0x2e7900 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)
49 Medial                         0x4e9bd8 kfun:androidx.compose.ui.window.MetalRedrawer.$draw$lambda$4$FUNCTION_REFERENCE$4.invoke#internal + 579 (Canvas.kt:579)
50 Medial                         0x4eb584 kfun:androidx.compose.ui.window.MetalRedrawer.$draw$lambda$4$FUNCTION_REFERENCE$4.$<bridge-UNN>invoke(){}#internal + 428 (MetalRedrawer.kt:428)
51 Medial                         0x4eb700 kfun:androidx.compose.ui.window.MetalRedrawer.$draw$lambda$5$FUNCTION_REFERENCE$5.$<bridge-UNN>invoke(){}#internal + 15 (ObjectiveCUtils.kt:15)
52 Medial                         0x127f43c ___6f72672e6a6574627261696e732e636f6d706f73652e75693a75692f6f70742f6275696c644167656e742f776f726b2f356234626566333562333562396631322f636f6d706f73652f75692f75692f7372632f75696b69744d61696e2f6b6f746c696e2f616e64726f6964782f636f6d706f73652f75692f77696e646f772f4d6574616c52656472617765722e6b74_knbridge114_block_invoke + 4318688316
53 libdispatch.dylib              0x26a8 _dispatch_call_block_and_release + 32
54 libdispatch.dylib              0x4300 _dispatch_client_callout + 20
55 libdispatch.dylib              0xb894 _dispatch_lane_serial_drain + 748
56 libdispatch.dylib              0xc3c4 _dispatch_lane_invoke + 380
57 libdispatch.dylib              0x17004 _dispatch_root_queue_drain_deferred_wlh + 288
58 libdispatch.dylib              0x16878 _dispatch_workloop_worker_thread + 404
59 libsystem_pthread.dylib        0x1964 _pthread_wqthread + 288
60 libsystem_pthread.dylib        0x1a04 start_wqthread + 8

Another trace

Crashed: RenderingDispatchQueue
0  Medial                         0x150ae74 GrGpuResource::release() + 32
1  Medial                         0x150ae70 GrGpuResource::release() + 28
2  Medial                         0x1517774 GrResourceCache::purgeAsNeeded() + 188
3  Medial                         0x15179e4 GrResourceCache::insertResource(GrGpuResource*) + 340
4  Medial                         0x15df58c GrMtlBuffer::GrMtlBuffer(GrMtlGpu*, unsigned long, GrGpuBufferType, GrAccessPattern, std::__1::basic_string_view<char, std::__1::char_traits<char>>) + 200
5  Medial                         0x15df498 GrMtlBuffer::Make(GrMtlGpu*, unsigned long, GrGpuBufferType, GrAccessPattern) + 80
6  Medial                         0x15099ac GrGpu::createBuffer(unsigned long, GrGpuBufferType, GrAccessPattern) + 264
7  Medial                         0x151c85c GrResourceProvider::createBuffer(unsigned long, GrGpuBufferType, GrAccessPattern, GrResourceProvider::ZeroInit) + 348
8  Medial                         0x151dcec GrStagingBufferManager::allocateStagingBufferSlice(unsigned long, unsigned long) + 168
9  Medial                         0x15e5298 GrMtlGpu::uploadToTexture(GrMtlTexture*, SkIRect, GrColorType, GrMipLevel const*, int) + 468
10 Medial                         0x15095d4 GrGpu::writePixels(GrSurface*, SkIRect, GrColorType, GrColorType, GrMipLevel const*, int, bool) + 548
11 Medial                         0x15090e8 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>>) + 472
12 Medial                         0x151b6b8 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>>) + 500
13 Medial                         0x151bf58 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>>) + 132
14 Medial                         0x1511600 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&) + 136
15 Medial                         0x151f8c4 GrSurfaceProxyPriv::doLazyInstantiation(GrResourceProvider*) + 372
16 Medial                         0x1510260 GrProxyProvider::createProxyFromBitmap(SkBitmap const&, GrMipmapped, SkBackingFit, SkBudgeted) + 588
17 Medial                         0x1528508 make_bmp_proxy(GrProxyProvider*, SkBitmap const&, GrColorType, GrMipmapped, SkBackingFit, SkBudgeted) + 124
18 Medial                         0x1528168 GrMakeCachedBitmapProxyView(GrRecordingContext*, SkBitmap const&, std::__1::basic_string_view<char, std::__1::char_traits<char>>, GrMipmapped) + 484
19 Medial                         0x14eb05c (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) + 3008
20 Medial                         0x14ec10c skgpu::v1::Device::drawImageQuad(SkImage const*, SkRect const*, SkRect const*, SkPoint const*, GrQuadAAFlags, SkMatrix const*, SkSamplingOptions const&, SkPaint const&, SkCanvas::SrcRectConstraint) + 3104
21 Medial                         0x14e8300 skgpu::v1::Device::drawImageRect(SkImage const*, SkRect const*, SkRect const&, SkSamplingOptions const&, SkPaint const&, SkCanvas::SrcRectConstraint) + 72
22 Medial                         0x1323838 SkCanvas::onDrawImageRect2(SkImage const*, SkRect const&, SkRect const&, SkSamplingOptions const&, SkPaint const*, SkCanvas::SrcRectConstraint) + 384
23 Medial                         0x1398d2c SkRecordDraw(SkRecord const&, SkCanvas*, SkPicture const* const*, SkDrawable* const*, int, SkBBoxHierarchy const*, SkPicture::AbortCallback*) + 452
24 Medial                         0x1325328 SkCanvas::onDrawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 196
25 Medial                         0x1325220 SkCanvas::drawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 364
26 Medial                         0x1398d2c SkRecordDraw(SkRecord const&, SkCanvas*, SkPicture const* const*, SkDrawable* const*, int, SkBBoxHierarchy const*, SkPicture::AbortCallback*) + 452
27 Medial                         0x1325328 SkCanvas::onDrawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 196
28 Medial                         0x1325220 SkCanvas::drawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 364
29 Medial                         0x1398d2c SkRecordDraw(SkRecord const&, SkCanvas*, SkPicture const* const*, SkDrawable* const*, int, SkBBoxHierarchy const*, SkPicture::AbortCallback*) + 452
30 Medial                         0x1325328 SkCanvas::onDrawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 196
31 Medial                         0x1325220 SkCanvas::drawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 364
32 Medial                         0x1398d2c SkRecordDraw(SkRecord const&, SkCanvas*, SkPicture const* const*, SkDrawable* const*, int, SkBBoxHierarchy const*, SkPicture::AbortCallback*) + 452
33 Medial                         0x1325328 SkCanvas::onDrawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 196
34 Medial                         0x1325220 SkCanvas::drawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 364
35 Medial                         0x1398d2c SkRecordDraw(SkRecord const&, SkCanvas*, SkPicture const* const*, SkDrawable* const*, int, SkBBoxHierarchy const*, SkPicture::AbortCallback*) + 452
36 Medial                         0x1325328 SkCanvas::onDrawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 196
37 Medial                         0x1325220 SkCanvas::drawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 364
38 Medial                         0x1398d2c SkRecordDraw(SkRecord const&, SkCanvas*, SkPicture const* const*, SkDrawable* const*, int, SkBBoxHierarchy const*, SkPicture::AbortCallback*) + 452
39 Medial                         0x1325328 SkCanvas::onDrawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 196
40 Medial                         0x1325220 SkCanvas::drawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 364
41 Medial                         0x1398d2c SkRecordDraw(SkRecord const&, SkCanvas*, SkPicture const* const*, SkDrawable* const*, int, SkBBoxHierarchy const*, SkPicture::AbortCallback*) + 452
42 Medial                         0x1325328 SkCanvas::onDrawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 196
43 Medial                         0x1325220 SkCanvas::drawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 364
44 Medial                         0x1398d2c SkRecordDraw(SkRecord const&, SkCanvas*, SkPicture const* const*, SkDrawable* const*, int, SkBBoxHierarchy const*, SkPicture::AbortCallback*) + 452
45 Medial                         0x1325328 SkCanvas::onDrawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 196
46 Medial                         0x1325220 SkCanvas::drawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 364
47 Medial                         0x1398d2c SkRecordDraw(SkRecord const&, SkCanvas*, SkPicture const* const*, SkDrawable* const*, int, SkBBoxHierarchy const*, SkPicture::AbortCallback*) + 452
48 Medial                         0x1325328 SkCanvas::onDrawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 196
49 Medial                         0x1325220 SkCanvas::drawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 364
50 Medial                         0x1398d2c SkRecordDraw(SkRecord const&, SkCanvas*, SkPicture const* const*, SkDrawable* const*, int, SkBBoxHierarchy const*, SkPicture::AbortCallback*) + 452
51 Medial                         0x1325328 SkCanvas::onDrawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 196
52 Medial                         0x1325220 SkCanvas::drawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 364
53 Medial                         0x1398d2c SkRecordDraw(SkRecord const&, SkCanvas*, SkPicture const* const*, SkDrawable* const*, int, SkBBoxHierarchy const*, SkPicture::AbortCallback*) + 452
54 Medial                         0x1325328 SkCanvas::onDrawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 196
55 Medial                         0x1325220 SkCanvas::drawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 364
56 Medial                         0x1398d2c SkRecordDraw(SkRecord const&, SkCanvas*, SkPicture const* const*, SkDrawable* const*, int, SkBBoxHierarchy const*, SkPicture::AbortCallback*) + 452
57 Medial                         0x1325328 SkCanvas::onDrawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 196
58 Medial                         0x1325220 SkCanvas::drawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 364
59 Medial                         0x1870f60 org_jetbrains_skia_Canvas__1nDrawPicture + 64
60 Medial                         0x2e4dd8 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)
61 Medial                         0x4e7848 kfun:androidx.compose.ui.window.MetalRedrawer.$draw$lambda$4$FUNCTION_REFERENCE$4.invoke#internal + 579 (Canvas.kt:579)
62 Medial                         0x4e91f4 kfun:androidx.compose.ui.window.MetalRedrawer.$draw$lambda$4$FUNCTION_REFERENCE$4.$<bridge-UNN>invoke(){}#internal + 428 (MetalRedrawer.kt:428)
63 Medial                         0x4e9370 kfun:androidx.compose.ui.window.MetalRedrawer.$draw$lambda$5$FUNCTION_REFERENCE$5.$<bridge-UNN>invoke(){}#internal + 15 (ObjectiveCUtils.kt:15)
64 Medial                         0x1298780 ___6f72672e6a6574627261696e732e636f6d706f73652e75693a75692f6f70742f6275696c644167656e742f776f726b2f356234626566333562333562396631322f636f6d706f73652f75692f75692f7372632f75696b69744d61696e2f6b6f746c696e2f616e64726f6964782f636f6d706f73652f75692f77696e646f772f4d6574616c52656472617765722e6b74_knbridge114_block_invoke + 400
65 libdispatch.dylib              0x2320 _dispatch_call_block_and_release + 32
66 libdispatch.dylib              0x3eac _dispatch_client_callout + 20
67 libdispatch.dylib              0xb534 _dispatch_lane_serial_drain + 668
68 libdispatch.dylib              0xc0a4 _dispatch_lane_invoke + 384
69 libdispatch.dylib              0x16cdc _dispatch_workloop_worker_thread + 648
70 libsystem_pthread.dylib        0xddc _pthread_wqthread + 288
71 libsystem_pthread.dylib        0xb7c start_wqthread + 8

elijah-semyonov added a commit to JetBrains/compose-multiplatform-core that referenced this issue Nov 6, 2023
## Proposed Changes

Since there are no reliable repros, it's a speculative fix for [the
crash](JetBrains/compose-multiplatform#3862)
on iOS.
It's based on an assumption that the case for the crash is caused by
render command encoding in a separate thread being performed after (or
in parallel) with the context disposal on the main thread which leads to
incorrect state inside Skia.

## Testing

Test: see if issues persists.

## Issues Fixed

Fixes: JetBrains/compose-multiplatform#3862

## Note
Skia is supposed to handle internal resources based on reference
counting and assumed scenario shouldn't lead to the crash, since the
context should be indirectly retained by the moment encoding starts.
Revert if issue persists because that logic would be redundant.
@elijah-semyonov
Copy link
Contributor

@juhaodong @LaatonWalaBhoot @onseok
I'm planning to do a dev release with speculative fix for this issue tomorrow, against which you can rebuild the app and distribute it to the users.
As of now, could you please make sure that didReceiveMemoryWarning is not called on the users that are affected by this crash?

Do your apps contain a lot of images?

@LaatonWalaBhoot
Copy link

LaatonWalaBhoot commented Nov 6, 2023

I will have to check about the didReceiveMemoryWarning
Yes my app has a lot of images because of the style news display
Thanks a lot. Waiting on the release.

@juhaodong
Copy link

@juhaodong @LaatonWalaBhoot @onseok
I'm planning to do a dev release with speculative fix for this issue tomorrow, against which you can rebuild the app and distribute it to the users.
As of now, could you please make sure that didReceiveMemoryWarning is not called on the users that are affected by this crash?

Do your apps contain a lot of images?

  1. Not sure, never checked that
  2. Yes! It got better when I cache all the image in the memory at the beginning, but on other platform we don't need to do that

@LaatonWalaBhoot
Copy link

LaatonWalaBhoot commented Nov 6, 2023

@elijah-semyonov
Another recent stack traces
Not sure if it's linked to the same issue.

Crashed: RenderingDispatchQueue
0  libsystem_kernel.dylib         0xa01c __pthread_kill + 8
1  libsystem_pthread.dylib        0x5680 pthread_kill + 268
2  libsystem_c.dylib              0x75bb0 abort + 180
3  libc++abi.dylib                0x11660 __cxxabiv1::__aligned_malloc_with_fallback(unsigned long) + 130
4  libc++abi.dylib                0x11038 __cxa_deleted_virtual + 22
5  Medial                         0x1518ee4 GrRenderTask::makeClosed(GrRecordingContext*) + 4400336612
6  Medial                         0x15040e4 GrDrawingManager::newOpsTask(GrSurfaceProxyView, sk_sp<GrArenas>) + 4400251108
7  Medial                         0x153ce68 skgpu::v1::SurfaceFillContext::replaceOpsTask() + 4400483944
8  Medial                         0x153dd98 skgpu::v1::SurfaceFillContext::internalClear(SkIRect const*, std::__1::array<float, 4ul>, bool) + 4400487832
9  Medial                         0x15376bc skgpu::v1::SurfaceDrawContext::attemptQuadOptimization(GrClip const*, GrUserStencilSettings const*, DrawQuad*, GrPaint*) + 4400461500
10 Medial                         0x1537d4c skgpu::v1::SurfaceDrawContext::drawFilledQuad(GrClip const*, GrPaint&&, DrawQuad*, GrUserStencilSettings const*) + 4400463180
11 Medial                         0x1536d98 skgpu::v1::SurfaceDrawContext::fillRectToRect(GrClip const*, GrPaint&&, GrAA, SkMatrix const&, SkRect const&, SkRect const&) + 4400459160
12 Medial                         0x1536a10 skgpu::v1::SurfaceDrawContext::drawPaint(GrClip const*, GrPaint&&, SkMatrix const&) + 4400458256
13 Medial                         0x14eabd0 skgpu::v1::Device::drawPaint(SkPaint const&) + 4400147408
14 Medial                         0x1327838 SkCanvas::internalDrawPaint(SkPaint const&) + 4398299192
15 Medial                         0x1326574 SkCanvas::drawPaint(SkPaint const&) + 4398294388
16 Medial                         0x139dfc8 SkRecordDraw(SkRecord const&, SkCanvas*, SkPicture const* const*, SkDrawable* const*, int, SkBBoxHierarchy const*, SkPicture::AbortCallback*) + 4398784456
17 Medial                         0x132a5c4 SkCanvas::onDrawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 4398310852
18 Medial                         0x132a4bc SkCanvas::drawPicture(SkPicture const*, SkMatrix const*, SkPaint const*) + 4398310588
19 Medial                         0x18761fc org_jetbrains_skia_Canvas__1nDrawPicture + 4403864060
20 Medial                         0x2e8dd8 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)
21 Medial                         0x4eb848 kfun:androidx.compose.ui.window.MetalRedrawer.$draw$lambda$4$FUNCTION_REFERENCE$4.invoke#internal + 579 (Canvas.kt:579)
22 Medial                         0x4ed1f4 kfun:androidx.compose.ui.window.MetalRedrawer.$draw$lambda$4$FUNCTION_REFERENCE$4.$<bridge-UNN>invoke(){}#internal + 428 (MetalRedrawer.kt:428)
23 Medial                         0x4ed370 kfun:androidx.compose.ui.window.MetalRedrawer.$draw$lambda$5$FUNCTION_REFERENCE$5.$<bridge-UNN>invoke(){}#internal + 15 (ObjectiveCUtils.kt:15)
24 Medial                         0x129da1c ___6f72672e6a6574627261696e732e636f6d706f73652e75693a75692f6f70742f6275696c644167656e742f776f726b2f356234626566333562333562396631322f636f6d706f73652f75692f75692f7372632f75696b69744d61696e2f6b6f746c696e2f616e64726f6964782f636f6d706f73652f75692f77696e646f772f4d6574616c52656472617765722e6b74_knbridge114_block_invoke + 4397734428
25 libdispatch.dylib              0x26a8 _dispatch_call_block_and_release + 32
26 libdispatch.dylib              0x4300 _dispatch_client_callout + 20
27 libdispatch.dylib              0xb894 _dispatch_lane_serial_drain + 748
28 libdispatch.dylib              0xc3c4 _dispatch_lane_invoke + 380
29 libdispatch.dylib              0x17004 _dispatch_root_queue_drain_deferred_wlh + 288
30 libdispatch.dylib              0x16878 _dispatch_workloop_worker_thread + 404
31 libsystem_pthread.dylib        0x1964 _pthread_wqthread + 288
32 libsystem_pthread.dylib        0x1a04 start_wqthread + 8
Crashed: com.apple.main-thread
0  Medial                         0x15166b0 SkTHashTable<GrTextureProxy*, skgpu::UniqueKey, SkTDynamicHash<GrTextureProxy, skgpu::UniqueKey, GrProxyProvider::UniquelyKeyedProxyHashTraits>::AdaptedTraits>::find(skgpu::UniqueKey const&) const + 4365559472
1  Medial                         0x1516170 GrProxyProvider::processInvalidUniqueKeyImpl(skgpu::UniqueKey const&, GrTextureProxy*, GrProxyProvider::InvalidateGPUResource, GrProxyProvider::RemoveTableEntry) + 4365558128
2  Medial                         0x1516170 GrProxyProvider::processInvalidUniqueKeyImpl(skgpu::UniqueKey const&, GrTextureProxy*, GrProxyProvider::InvalidateGPUResource, GrProxyProvider::RemoveTableEntry) + 4365558128
3  Medial                         0x151c9dc GrResourceCache::purgeAsNeeded() + 4365584860
4  Medial                         0x151cc80 GrResourceCache::insertResource(GrGpuResource*) + 4365585536
5  Medial                         0x15e40c8 GrMtlAttachment::GrMtlAttachment(GrMtlGpu*, SkISize, GrAttachment::UsageFlags, id<MTLTexture>, GrWrapCacheable, std::__1::basic_string_view<char, GrWrapCacheable::char_traits<char>>) + 4366401736
6  Medial                         0x15e4424 GrMtlAttachment::MakeWrapped(GrMtlGpu*, SkISize, id<MTLTexture>, GrAttachment::UsageFlags, GrWrapCacheable, std::__1::basic_string_view<char, GrWrapCacheable::char_traits<char>>) + 4366402596
7  Medial                         0x15f4f58 GrMtlRenderTarget::MakeWrappedRenderTarget(GrMtlGpu*, SkISize, int, id<MTLTexture>) + 4366471000
8  Medial                         0x15eb5c0 GrMtlGpu::onWrapBackendRenderTarget(GrBackendRenderTarget const&) + 4366431680
9  Medial                         0x150eafc GrGpu::wrapBackendRenderTarget(GrBackendRenderTarget const&) + 4365527804
10 Medial                         0x1515d98 GrProxyProvider::wrapBackendRenderTarget(GrBackendRenderTarget const&, sk_sp<skgpu::RefCntedCallback>) + 4365557144
11 Medial                         0x15bf108 SkSurface::MakeFromBackendRenderTarget(GrRecordingContext*, GrBackendRenderTarget const&, GrSurfaceOrigin, SkColorType, sk_sp<SkColorSpace>, SkSurfaceProps const*, void (*)(void*), void*) + 4366250248
12 Medial                         0x1870ed8 org_jetbrains_skia_Surface__1nMakeFromBackendRenderTarget + 4369075928
13 Medial                         0x4e9bcc kfun:androidx.compose.ui.window.MetalRedrawer.draw#internal + 4348599244 (Native.native.kt:4348599244)
14 Medial                         0x4eaaf0 kfun:androidx.compose.ui.window.MetalRedrawer.$<init>$lambda$0$FUNCTION_REFERENCE$0.$<bridge-UNN>invoke(){}#internal + 253 (MetalRedrawer.kt:253)
15 Medial                         0x4ed884 kfun:androidx.compose.ui.window.DisplayLinkProxy.$imp:handleDisplayLinkTick#internal + 454 (MetalRedrawer.kt:454)
16 QuartzCore                     0x301fc CA::Display::DisplayLinkItem::dispatch_(CA::SignPost::Interval<(CA::SignPost::CAEventCode)835322056>&) + 48
17 QuartzCore                     0x333e4 CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 864
18 QuartzCore                     0x32ef0 CA::Display::DisplayLink::callback(_CADisplayTimer*, unsigned long long, unsigned long long, unsigned long long, bool, void*) + 844
19 QuartzCore                     0xb1338 CA::Display::DisplayLink::dispatch_deferred_display_links(unsigned int) + 348
20 UIKitCore                      0xaad40 _UIUpdateSequenceRun + 84
21 UIKitCore                      0xaa430 schedulerStepScheduledMainSection + 144
22 UIKitCore                      0xaa4ec runloopSourceCallback + 92
23 CoreFoundation                 0x37acc __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28
24 CoreFoundation                 0x36d48 __CFRunLoopDoSource0 + 176
25 CoreFoundation                 0x354fc __CFRunLoopDoSources0 + 244
26 CoreFoundation                 0x34238 __CFRunLoopRun + 828
27 CoreFoundation                 0x33e18 CFRunLoopRunSpecific + 608
28 GraphicsServices               0x35ec GSEventRunModal + 164
29 UIKitCore                      0x22f2fc -[UIApplication _run] + 888
30 UIKitCore                      0x22e938 UIApplicationMain + 340
31 SwiftUI                        0x114d354 OUTLINED_FUNCTION_31 + 604
32 SwiftUI                        0x114d198 OUTLINED_FUNCTION_31 + 160
33 SwiftUI                        0xdca434 OUTLINED_FUNCTION_26 + 2196
34 Medial                         0x8670 main + 4343481968 (iOSApp.swift:4343481968)
35 ???                            0x1be303d44 (Missing)

@onseok
Copy link
Author

onseok commented Nov 6, 2023

@juhaodong @LaatonWalaBhoot @onseok I'm planning to do a dev release with speculative fix for this issue tomorrow, against which you can rebuild the app and distribute it to the users. As of now, could you please make sure that didReceiveMemoryWarning is not called on the users that are affected by this crash?

Do your apps contain a lot of images?

I appreciate the heads-up on the dev release. Regarding didReceiveMemoryWarning, I'm not entirely sure as I haven't encountered it before or checked for it specifically in our app, I will need to investigate further as I am not familiar with this. But yes, our app does use a significant amount of image loading.

@elijah-semyonov
Copy link
Contributor

elijah-semyonov commented Nov 7, 2023

This information will also help:

What is the previous compose version, that wasn't affected by this crash?

@LaatonWalaBhoot

Multiple reports of instances crashing after resuming and scrolling the app.

Does the app have an image picker during which the app could be sent into background?

@elijah-semyonov
Copy link
Contributor

elijah-semyonov commented Nov 7, 2023

I will add temporary experimental flag on incoming dev build:

You can arbitrarily set forceMainThreadRendering in androidx.compose.ui.window to true during the app startup in iOS sourceset. A/B test on users to bisect this to be a reason for crashes will be a solid help.

@LaatonWalaBhoot
Copy link

LaatonWalaBhoot commented Nov 7, 2023

@elijah-semyonov
One of the places it definitely crashes is after selecting email from Google login modal during login process.

Another instance is after resuming app from the tray.

Have used compose versions
1.5.1 and 1.5.10 both have been affected.
Don't know any other version which wasn't.

Will add the check in iOS source sets. There are different stack traces. Does that provide any info about what might be causing this?

@elijah-semyonov
Copy link
Contributor

Thank you, it certainly adds some context to be used during further investigation.

@LaatonWalaBhoot
Copy link

It would seem resuming view controllers might be the case.
After logging in. The main view controller is resumed from the presenting Google auth view controller.
Same happens when we bring the app to front from background.

@pjBooms
Copy link
Collaborator

pjBooms commented Nov 9, 2023

However, what do you guys suggest as the best way to load fonts for now apart from MOKO because this is a major blocker?

We are going to add support for fonts into our resource library next release

Plus the white background of UIKitView causes blinking which looks bad in dark mode. Any idea when this will be fixed properly?

Do you mean this issue?

@LaatonWalaBhoot
Copy link

Any tentative date for the next release with the fixes?
Yes, that same issue. The blinking is horrible. Lottie and other libraries for auth blink in dark mode and look ugly.
In fact any UI specific to iOS would see this problem in dark mode.

@pjBooms
Copy link
Collaborator

pjBooms commented Nov 10, 2023

Any tentative date for the next release with the fixes?

It is a hard problem, we are investigating it right now. Currently we cannot provide estimations as it is still not clear what is the root cause.

@LaatonWalaBhoot
Copy link

No worries. Thanks a lot for the help. For now, using the flag forceMainThreadRendering = true has subsided the crashes.
For anyone else looking for a fix for the font crash. Using a single font flavor in the font family stopped the font crashes as well. Not sure if it's a MOKO or CMP issue.

Eagerly waiting for the new release @pjBooms. Hopefully, UIKitView problems and resource library updates will be solved.

@GuilhE
Copy link
Contributor

GuilhE commented Nov 10, 2023

For anyone else looking for a fix for the font crash. Using a single font flavor in the font family stopped the font crashes as well. Not sure if it's a MOKO or CMP issue.

By "single font flavor in the font family", do you mean only one font file? If So, I use only one and it crashes. I don't use MOKO also, instead, just raw expect/actual.

@LaatonWalaBhoot
Copy link

@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.

@Composable
fun SansSerifCondensed() = fontFamilyResource(Res.fonts.RobotoCondensed.medium)

@Composable
fun MedialTypography(): Typography {
    val sansSerifCondensed = SansSerifCondensed()

    return Typography(
        labelLarge = TextStyle(
            fontFamily = sansSerifCondensed,
            fontWeight = FontWeight.Medium,
            letterSpacing = 0.10000000149011612.sp,
            lineHeight = 20.sp,
            fontSize = 14.sp
        ),
        labelMedium = TextStyle(
            fontFamily = sansSerifCondensed,
            fontWeight = FontWeight.Medium,
            letterSpacing = 0.5.sp,
            lineHeight = 16.sp,
            fontSize = 12.sp
        ),
        labelSmall = TextStyle(
            fontFamily = sansSerifCondensed,
            fontWeight = FontWeight.Medium,
            letterSpacing = 0.5.sp,
            lineHeight = 16.sp,
            fontSize = 11.sp
        ),
        bodyLarge = TextStyle(
            fontFamily = sansSerifCondensed,
            fontWeight = FontWeight.W400,
            letterSpacing = 0.5.sp,
            lineHeight = 24.sp,
            fontSize = 16.sp
        ),
        bodyMedium = TextStyle(
            fontFamily = sansSerifCondensed,
            fontWeight = FontWeight.W400,
            letterSpacing = 0.25.sp,
            lineHeight = 20.sp,
            fontSize = 14.sp
        ),
        bodySmall = TextStyle(
            fontFamily = sansSerifCondensed,
            fontWeight = FontWeight.W400,
            letterSpacing = 0.4000000059604645.sp,
            lineHeight = 16.sp,
            fontSize = 12.sp
        ),
        headlineLarge = TextStyle(
            fontFamily = sansSerifCondensed,
            fontWeight = FontWeight.W400,
            letterSpacing = 0.sp,
            lineHeight = 40.sp,
            fontSize = 32.sp
        ),
        headlineMedium = TextStyle(
            fontFamily = sansSerifCondensed,
            fontWeight = FontWeight.W400,
            letterSpacing = 0.sp,
            lineHeight = 36.sp,
            fontSize = 28.sp
        ),
        headlineSmall = TextStyle(
            fontFamily = sansSerifCondensed,
            fontWeight = FontWeight.W400,
            letterSpacing = 0.sp,
            lineHeight = 32.sp,
            fontSize = 24.sp
        ),
        displayLarge = TextStyle(
            fontFamily = sansSerifCondensed,
            fontWeight = FontWeight.W400,
            letterSpacing = (-0.25).sp,
            lineHeight = 64.sp,
            fontSize = 57.sp
        ),
        displayMedium = TextStyle(
            fontFamily = sansSerifCondensed,
            fontWeight = FontWeight.W400,
            letterSpacing = 0.sp,
            lineHeight = 52.sp,
            fontSize = 45.sp
        ),
        displaySmall = TextStyle(
            fontFamily = sansSerifCondensed,
            fontWeight = FontWeight.W400,
            letterSpacing = 0.sp,
            lineHeight = 44.sp,
            fontSize = 36.sp
        ),
        titleLarge = TextStyle(
            fontFamily = sansSerifCondensed,
            fontWeight = FontWeight.W400,
            letterSpacing = 0.sp,
            lineHeight = 28.sp,
            fontSize = 22.sp
        ),
        titleMedium = TextStyle(
            fontFamily = sansSerifCondensed,
            fontWeight = FontWeight.Medium,
            letterSpacing = 0.15000000596046448.sp,
            lineHeight = 24.sp,
            fontSize = 16.sp
        ),
        titleSmall = TextStyle(
            fontFamily = sansSerifCondensed,
            fontWeight = FontWeight.Medium,
            letterSpacing = 0.10000000149011612.sp,
            lineHeight = 20.sp,
            fontSize = 14.sp
        )
    )

}

@GuilhE
Copy link
Contributor

GuilhE commented Nov 10, 2023

Oh but this approach works for me, it stopped working properly starting from 1.5.10-rc01, that's why I opened this issue. With the latest versions, in my use case, it's harder to reproduce, but it's still there.

@LaatonWalaBhoot
Copy link

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.

@dima-avdeev-jb
Copy link
Contributor

dima-avdeev-jb commented Nov 10, 2023

We fixed Crash with fonts.
Please take a look at this comment in another Issue: #3822 (comment)

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 use forceMainThreadRendering

@LaatonWalaBhoot
Copy link

LaatonWalaBhoot commented Nov 10, 2023

@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?

@dima-avdeev-jb
Copy link
Contributor

@LaatonWalaBhoot
It is good to test with Compose version 1.5.10 and with 0.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

@LaatonWalaBhoot
Copy link

LaatonWalaBhoot commented Nov 11, 2023

@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 with 1.5.10 and 0.0.0-dev1260
For now moving to production with 0.0.0-dev1260 and forceMainThreadRendering = true
Hope this gets resolved in 1.5.11.
Would UIKitView white background also get addressed in 1.5.11?

Stacktrace:

Crashed: RenderingDispatchQueue
0  libobjc.A.dylib                0x8238 objc_loadWeakRetained + 144
1  Medial                         0x10cc520 GrMtlPipelineState::setDepthStencilState(GrMtlRenderCommandEncoder*) + 160
2  Medial                         0x10cc46c GrMtlPipelineState::setDrawState(GrMtlRenderCommandEncoder*, skgpu::Swizzle const&, GrXferProcessor const&) + 208
3  Medial                         0x10cacc8 GrMtlOpsRenderPass::onBindPipeline(GrProgramInfo const&, SkRect const&) + 292
4  Medial                         0xfe63ac GrOpsRenderPass::bindPipeline(GrProgramInfo const&, SkRect const&) + 164
5  Medial                         0x108845c (anonymous namespace)::TextureOpImpl::onExecute(GrOpFlushState*, SkRect const&) + 132
6  Medial                         0x10739f0 GrOp::execute(GrOpFlushState*, SkRect const&) + 232
7  Medial                         0x10737d0 skgpu::ganesh::OpsTask::onExecute(GrOpFlushState*) + 1036
8  Medial                         0xfd2c6c GrDrawingManager::executeRenderTasks(GrOpFlushState*) + 188
9  Medial                         0xfd2644 GrDrawingManager::flush(SkSpan<GrSurfaceProxy*>, SkSurfaces::BackendSurfaceAccess, GrFlushInfo const&, skgpu::MutableTextureState const*) + 1440
10 Medial                         0xfd2e78 GrDrawingManager::flushSurfaces(SkSpan<GrSurfaceProxy*>, SkSurfaces::BackendSurfaceAccess, GrFlushInfo const&, skgpu::MutableTextureState const*) + 168
11 Medial                         0xfcd5f0 GrDirectContextPriv::flushSurfaces(SkSpan<GrSurfaceProxy*>, SkSurfaces::BackendSurfaceAccess, GrFlushInfo const&, skgpu::MutableTextureState const*) + 360
12 Medial                         0xfcc5c8 GrDirectContext::flush(SkSurface*, SkSurfaces::BackendSurfaceAccess, GrFlushInfo const&) + 148
13 Medial                         0xec0394 SkSurface::flushAndSubmit(bool) + 84
14 Medial                         0x3b9c88 kfun:androidx.compose.ui.window.MetalRedrawer.$draw$lambda$4$FUNCTION_REFERENCE$4.invoke#internal + 952 (Surface.kt:952)
15 Medial                         0x3bb128 kfun:androidx.compose.ui.window.MetalRedrawer.$draw$lambda$4$FUNCTION_REFERENCE$4.$<bridge-UNN>invoke(){}#internal + 428 (MetalRedrawer.kt:428)
16 Medial                         0x948298 kfun:kotlin.Function0#invoke(){}1:0-trampoline + 1 ([K][Suspend]Functions:1)
17 Medial                         0x3bb1e8 kfun:androidx.compose.ui.window.MetalRedrawer.$draw$lambda$5$FUNCTION_REFERENCE$5.$<bridge-UNN>invoke(){}#internal + 15 (ObjectiveCUtils.kt:15)
18 Medial                         0x948298 kfun:kotlin.Function0#invoke(){}1:0-trampoline + 1 ([K][Suspend]Functions:1)
19 Medial                         0xd9bdb0 ___6f72672e6a6574627261696e732e636f6d706f73652e75693a75692f6f70742f6275696c644167656e742f776f726b2f356234626566333562333562396631322f636f6d706f73652f75692f75692f7372632f75696b69744d61696e2f6b6f746c696e2f616e64726f6964782f636f6d706f73652f75692f77696e646f772f4d6574616c52656472617765722e6b74_knbridge114_block_invoke + 200
20 libdispatch.dylib              0x2320 _dispatch_call_block_and_release + 32
21 libdispatch.dylib              0x3eac _dispatch_client_callout + 20
22 libdispatch.dylib              0xb534 _dispatch_lane_serial_drain + 668
23 libdispatch.dylib              0xc0a4 _dispatch_lane_invoke + 384
24 libdispatch.dylib              0x16cdc _dispatch_workloop_worker_thread + 648
25 libsystem_pthread.dylib        0xddc _pthread_wqthread + 288
26 libsystem_pthread.dylib        0xb7c start_wqthread + 8

@ToluwaniO
Copy link

I'm a bit late to the party but I encountered this issue after upgrading to 1.5.10-beta02. I've been stuck on 1.5.10-beta01 ever since. My app does have a ton of photos, it's a photo sharing app. I load images on ios with UIImage and the KingFisher library.

Crashed: com.apple.main-thread
0  Runwayy                        0x17b43e8 GrGpuResource::release() + 4354180072
1  Runwayy                        0x17c07cc GrResourceCache::releaseAll() + 4354230220
2  Runwayy                        0x17c07cc GrResourceCache::releaseAll() + 4354230220
3  Runwayy                        0x17a1704 GrDirectContext::~GrDirectContext() + 4354103044
4  Runwayy                        0x17a1888 GrDirectContext::~GrDirectContext() + 4354103432
5  Runwayy                        0x5d120c kfun:org.jetbrains.skia.impl.FinalizationThunk.clean#internal + 19 (Managed.native.kt:19)
6  Runwayy                        0x5d0ba4 kfun:org.jetbrains.skia.impl.Managed#close(){} + 1 (Native.native.kt:1)
7  Runwayy                        0x785b24 kfun:androidx.compose.ui.window.ComposeWindow#objc:viewDidDisappear: + 297 (MetalRedrawer.kt:297)
8  Runwayy                        0x1550368 _6f72672e6a6574627261696e732e636f6d706f73652e75693a75692f6f70742f6275696c644167656e742f776f726b2f356234626566333562333562396631322f636f6d706f73652f75692f75692f7372632f75696b69744d61696e2f6b6f746c696e2f616e64726f6964782f636f6d706f73652f75692f77696e646f772f436f6d706f736557696e646f772e75696b69742e6b74_kncfun368 + 4351673192
9  UIKitCore                      0xcbec -[UIViewController _setViewAppearState:isAnimating:] + 1012
10 UIKitCore                      0x7edb2c __52-[UIViewController _setViewAppearState:isAnimating:]_block_invoke_2 + 168
11 UIKitCore                      0x2457dc __52-[UIViewController _setViewAppearState:isAnimating:]_block_invoke + 192
12 CoreFoundation                 0xa1cc __NSARRAY_IS_CALLING_OUT_TO_A_BLOCK__ + 24
13 CoreFoundation                 0x376b8 -[__NSSingleObjectArrayI enumerateObjectsWithOptions:usingBlock:] + 92
14 UIKitCore                      0xcdd4 -[UIViewController _setViewAppearState:isAnimating:] + 1500
15 UIKitCore                      0x4672a8 -[UIViewController __viewDidDisappear:] + 136
16 UIKitCore                      0x2206c4 -[UIViewController _endAppearanceTransition:] + 192
17 UIKitCore                      0x14cef0 -[UINavigationController navigationTransitionView:didEndTransition:fromView:toView:] + 1100
18 UIKitCore                      0x1fd49c __49-[UINavigationController _startCustomTransition:]_block_invoke + 208
19 UIKitCore                      0x2b1d10 -[_UIViewControllerTransitionContext completeTransition:] + 116
20 UIKitCore                      0x80779c __53-[_UINavigationParallaxTransition animateTransition:]_block_invoke_5 + 604
21 UIKitCore                      0x1060598 __UIVIEW_IS_EXECUTING_ANIMATION_COMPLETION_BLOCK__ + 36
22 UIKitCore                      0xce148 -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 636
23 UIKitCore                      0xcd0a4 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 436
24 UIKitCore                      0xcc7c0 -[UIViewAnimationState animationDidStop:finished:] + 196
25 UIKitCore                      0xcc8d4 -[UIViewAnimationState animationDidStop:finished:] + 472
26 QuartzCore                     0x134e0 CA::Layer::run_animation_callbacks(void*) + 232
27 libdispatch.dylib              0x3eac _dispatch_client_callout + 20
28 libdispatch.dylib              0x126a4 _dispatch_main_queue_drain + 928
29 libdispatch.dylib              0x122f4 _dispatch_main_queue_callback_4CF + 44
30 CoreFoundation                 0x98c28 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16
31 CoreFoundation                 0x7a560 __CFRunLoopRun + 1992
32 CoreFoundation                 0x7f3ec CFRunLoopRunSpecific + 612
33 GraphicsServices               0x135c GSEventRunModal + 164
34 UIKitCore                      0x39cf58 -[UIApplication _run] + 888
35 UIKitCore                      0x39cbbc UIApplicationMain + 340
36 SwiftUI                        0x1bcc50 OUTLINED_FUNCTION_895 + 2472
37 SwiftUI                        0x1231ec block_copy_helper.1 + 496
38 SwiftUI                        0x10d294 OUTLINED_FUNCTION_901 + 2752
39 Runwayy                        0x6dc0 main + 4 (iOSApp.swift:4)
40 ???                            0x1e9ab4dec (Missing)

@dima-avdeev-jb
Copy link
Contributor

dima-avdeev-jb commented Nov 11, 2023

@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 for Crashed: 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.

@dima-avdeev-jb
Copy link
Contributor

@ToluwaniO can please provide a minial reproducible sample of your problem on GitHub ?

@LaatonWalaBhoot
Copy link

@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.

@elijah-semyonov
Copy link
Contributor

@LaatonWalaBhoot
Hi, could you kindly check if 0.0.0-dev1270 solves the issue (without forceMainThreadRendering)

@LaatonWalaBhoot
Copy link

@elijah-semyonov
Please spare me some time.
In the middle of the prod release. Will update you at the earliest

@pjBooms
Copy link
Collaborator

pjBooms commented Nov 16, 2023

@LaatonWalaBhoot have not you tried the 0.0.0-dev1270 build yet? We need to decide if we should disable parallel rendering in 1.5.11

@LaatonWalaBhoot
Copy link

@pjBooms
Not yet. But I will do it today. Please give me 12 hours to respond.
Apologies for the delay. Have been stuck with production release

@LaatonWalaBhoot
Copy link

@pjBooms @elijah-semyonov
The crash is still there with 0.0.0-dev1270 and without forceMainThreadRendering
Stacktrace

Crashed: RenderingDispatchQueue
0  libobjc.A.dylib                0x8238 objc_loadWeakRetained + 144
1  Medial                         0x10e6c34 GrMtlPipelineState::setDepthStencilState(GrMtlRenderCommandEncoder*) + 160
2  Medial                         0x10e6b80 GrMtlPipelineState::setDrawState(GrMtlRenderCommandEncoder*, skgpu::Swizzle const&, GrXferProcessor const&) + 208
3  Medial                         0x10e53dc GrMtlOpsRenderPass::onBindPipeline(GrProgramInfo const&, SkRect const&) + 292
4  Medial                         0x1000ac0 GrOpsRenderPass::bindPipeline(GrProgramInfo const&, SkRect const&) + 164
5  Medial                         0x10a2b70 (anonymous namespace)::TextureOpImpl::onExecute(GrOpFlushState*, SkRect const&) + 132
6  Medial                         0x108e104 GrOp::execute(GrOpFlushState*, SkRect const&) + 232
7  Medial                         0x108dee4 skgpu::ganesh::OpsTask::onExecute(GrOpFlushState*) + 1036
8  Medial                         0xfed380 GrDrawingManager::executeRenderTasks(GrOpFlushState*) + 188
9  Medial                         0xfecd58 GrDrawingManager::flush(SkSpan<GrSurfaceProxy*>, SkSurfaces::BackendSurfaceAccess, GrFlushInfo const&, skgpu::MutableTextureState const*) + 1440
10 Medial                         0xfed58c GrDrawingManager::flushSurfaces(SkSpan<GrSurfaceProxy*>, SkSurfaces::BackendSurfaceAccess, GrFlushInfo const&, skgpu::MutableTextureState const*) + 168
11 Medial                         0xfe7d04 GrDirectContextPriv::flushSurfaces(SkSpan<GrSurfaceProxy*>, SkSurfaces::BackendSurfaceAccess, GrFlushInfo const&, skgpu::MutableTextureState const*) + 360
12 Medial                         0xfe6cdc GrDirectContext::flush(SkSurface*, SkSurfaces::BackendSurfaceAccess, GrFlushInfo const&) + 148
13 Medial                         0xedaaa8 SkSurface::flushAndSubmit(bool) + 84
14 Medial                         0x3ba160 kfun:androidx.compose.ui.window.MetalRedrawer.$draw$lambda$4$FUNCTION_REFERENCE$4.invoke#internal + 956 (Surface.kt:956)
15 Medial                         0x3bb75c kfun:androidx.compose.ui.window.MetalRedrawer.$draw$lambda$4$FUNCTION_REFERENCE$4.$<bridge-UNNB>invoke(kotlin.Boolean){}#internal + 441 (MetalRedrawer.kt:441)
16 Medial                         0x950eb0 kfun:kotlin.Function1#invoke(1:0){}1:1-trampoline + 1 ([K][Suspend]Functions:1)
17 Medial                         0x3bb92c kfun:androidx.compose.ui.window.MetalRedrawer.$draw$lambda$5$FUNCTION_REFERENCE$5.$<bridge-UNN>invoke(){}#internal + 140 (LocalUIKitInteropContext.kt:140)
18 Medial                         0x951530 kfun:kotlin.Function0#invoke(){}1:0-trampoline + 1 ([K][Suspend]Functions:1)
19 Medial                         0xdb64c4 ___6f72672e6a6574627261696e732e636f6d706f73652e75693a75692f6f70742f6275696c644167656e742f776f726b2f356234626566333562333562396631322f636f6d706f73652f75692f75692f7372632f75696b69744d61696e2f6b6f746c696e2f616e64726f6964782f636f6d706f73652f75692f77696e646f772f4d6574616c52656472617765722e6b74_knbridge130_block_invoke + 200
20 libdispatch.dylib              0x2320 _dispatch_call_block_and_release + 32
21 libdispatch.dylib              0x3eac _dispatch_client_callout + 20
22 libdispatch.dylib              0xb534 _dispatch_lane_serial_drain + 668
23 libdispatch.dylib              0xc0a4 _dispatch_lane_invoke + 384
24 libdispatch.dylib              0x16cdc _dispatch_workloop_worker_thread + 648
25 libsystem_pthread.dylib        0xddc _pthread_wqthread + 288
26 libsystem_pthread.dylib        0xb7c start_wqthread + 8

elijah-semyonov added a commit to JetBrains/compose-multiplatform-core that referenced this issue Nov 17, 2023
## Proposed Changes

Using Skia context in multiple threads simultaneously leads to
occasional unreproducable crashes on users' side.
Roll back experimental #896. Disable the path for encoding rendering
commands on a separate thread until the scenario is resolved and
underlying issue is fixed.

## Testing

Test: N/A

## Issues Fixed

Fixes: JetBrains/compose-multiplatform#3862
igordmn pushed a commit to JetBrains/compose-multiplatform-core that referenced this issue Nov 20, 2023
## Proposed Changes

Using Skia context in multiple threads simultaneously leads to
occasional unreproducable crashes on users' side.
Roll back experimental #896. Disable the path for encoding rendering
commands on a separate thread until the scenario is resolved and
underlying issue is fixed.

## Testing

Test: N/A

## Issues Fixed

Fixes: JetBrains/compose-multiplatform#3862
mazunin-v-jb pushed a commit to JetBrains/compose-multiplatform-core that referenced this issue Dec 7, 2023
## Proposed Changes

Since there are no reliable repros, it's a speculative fix for [the
crash](JetBrains/compose-multiplatform#3862)
on iOS.
It's based on an assumption that the case for the crash is caused by
render command encoding in a separate thread being performed after (or
in parallel) with the context disposal on the main thread which leads to
incorrect state inside Skia.

## Testing

Test: see if issues persists.

## Issues Fixed

Fixes: JetBrains/compose-multiplatform#3862

## Note
Skia is supposed to handle internal resources based on reference
counting and assumed scenario shouldn't lead to the crash, since the
context should be indirectly retained by the moment encoding starts.
Revert if issue persists because that logic would be redundant.
mazunin-v-jb pushed a commit to JetBrains/compose-multiplatform-core that referenced this issue Dec 7, 2023
## Proposed Changes

Using Skia context in multiple threads simultaneously leads to
occasional unreproducable crashes on users' side.
Roll back experimental #896. Disable the path for encoding rendering
commands on a separate thread until the scenario is resolved and
underlying issue is fixed.

## Testing

Test: N/A

## Issues Fixed

Fixes: JetBrains/compose-multiplatform#3862
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment