JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
15.97k stars 1.16k forks source link

Runtime crash of the new Compose Multiplatform Mobile example on iOS #3110

Closed gleb-skobinsky closed 1 year ago

gleb-skobinsky commented 1 year ago

Description Upon creating a new project from the compose-multiplatform-ios-android-template and trying to run the iosApp configuration in Android Studio in a simulator, the app builds successfully, but crashes immediately after launching.

Affected platforms

Versions

To Reproduce Steps and/or the code snippet to reproduce the behavior:

  1. Configure dev tools and IDEs according to guide (https://github.com/JetBrains/compose-multiplatform-ios-android-template#readme)
  2. Create a new repository with the compose-multiplatform-ios-android-template and clone it.
  3. Open in Android Studio, edit Run Configurations, select simulator version, click OK.
  4. Run the configuration.
  5. After the build (that seems successful), see the stack trace:
    "/Users/glebg/Desktop/projects/brain-chat/build/ios/Debug-iphonesimulator/My application.app"
    Uncaught Kotlin exception: kotlin.NullPointerException
    at 0   My application                      0x104e72100        kfun:kotlin.Throwable#<init>(){} + 80 
    at 1   My application                      0x104e6ba99        kfun:kotlin.Exception#<init>(){} + 73 
    at 2   My application                      0x104e6bd79        kfun:kotlin.RuntimeException#<init>(){} + 73 
    at 3   My application                      0x104e6c619        kfun:kotlin.NullPointerException#<init>(){} + 73 
    at 4   My application                      0x104ea5754        ThrowNullPointerException + 132 
    at 5   My application                      0x10526db00        kfun:org.jetbrains.skiko.redrawer.MetalRedrawer#<init>(org.jetbrains.skiko.SkiaLayer){} + 992 
    at 6   My application                      0x10523d367        kfun:org.jetbrains.skiko.SkiaLayer#attachTo(platform.UIKit.UIView){} + 391 
    at 7   My application                      0x105257a39        kfun:org.jetbrains.skiko.SkikoUIView#load(){}org.jetbrains.skiko.SkikoUIView + 3513 
    at 8   My application                      0x10556e30a        kfun:androidx.compose.ui.window.ComposeWindow#objc:loadView + 1050 
    at 9   My application                      0x10557bbb3        _6f72672e6a6574627261696e732e636f6d706f73652e75693a75692f6f70742f6275696c644167656e742f776f726b2f313732653534366232326336306432622f636f6d706f73652f6672616d65776f726b732f737570706f72742f636f6d706f73652f75692f75692f7372632f75696b69744d61696e2f6b6f746c696e2f616e64726f6964782f636f6d706f73652f75692f77696e646f772f436f6d706f736557696e646f772e75696b69742e6b74_knbridge100 + 163 
    at 10  UIKitCore                           0x1106fce9b        -[UIViewController loadViewIfRequired] + 92 
    at 11  UIKitCore                           0x1106fd6c8        -[UIViewController view] + 26 
    at 12  SwiftUI                             0x1082c23d0        get_witness_table 7SwiftUI4ViewRzlAA15ModifiedContentVyxAA11_ClipEffectVyAA9RectangleVGGAaBHPxAaBHD1__AiA0C8ModifierHPyHCHCTm + 3795 
    at 13  SwiftUI                             0x1082c23be        get_witness_table 7SwiftUI4ViewRzlAA15ModifiedContentVyxAA11_ClipEffectVyAA9RectangleVGGAaBHPxAaBHD1__AiA0C8ModifierHPyHCHCTm + 3777 
    at 14  SwiftUI                             0x108b2402f        block_destroy_helper + 19040 
    at 15  SwiftUI                             0x108b23e67        block_destroy_helper + 18584 
    at 16  SwiftUI                             0x108b24e9b        block_destroy_helper + 22732 
    at 17  SwiftUI                             0x108b23f22        block_destroy_helper + 18771 
    at 18  SwiftUI                             0x1084b1784        get_witness_table 7SwiftUI4ViewRzlAA15ModifiedContentVyxAA30_EnvironmentKeyWritingModifierVyAA11FindContextVGGAaBHPxAaBHD1__AiA0cI0HPyHCHCTm + 15723 
    at 19  SwiftUI                             0x1084b58fd        get_witness_table 7SwiftUI4ViewRzlAA15ModifiedContentVyxAA30_EnvironmentKeyWritingModifierVyAA11FindContextVGGAaBHPxAaBHD1__AiA0cI0HPyHCHCTm + 32484 
    at 20  SwiftUI                             0x1084afcce        get_witness_table 7SwiftUI4ViewRzlAA15ModifiedContentVyxAA30_EnvironmentKeyWritingModifierVyAA11FindContextVGGAaBHPxAaBHD1__AiA0cI0HPyHCHCTm + 8885 
    at 21  SwiftUI                             0x1084b1657        get_witness_table 7SwiftUI4ViewRzlAA15ModifiedContentVyxAA30_EnvironmentKeyWritingModifierVyAA11FindContextVGGAaBHPxAaBHD1__AiA0cI0HPyHCHCTm + 15422 
    at 22  SwiftUI                             0x1084b0b60        get_witness_table 7SwiftUI4ViewRzlAA15ModifiedContentVyxAA30_EnvironmentKeyWritingModifierVyAA11FindContextVGGAaBHPxAaBHD1__AiA0cI0HPyHCHCTm + 12615 
    at 23  SwiftUI                             0x107bc3ff3        block_destroy_helper.6215 + 63948 
    at 24  AttributeGraph                      0x7ff81fd7a1d6     _ZN2AG5Graph11UpdateStack6updateEv + 536 
    at 25  AttributeGraph                      0x7ff81fd7a9aa     _ZN2AG5Graph16update_attributeENS_4data3ptrINS_4NodeEEEj + 442 
    at 26  AttributeGraph                      0x7ff81fd824f4     _ZN2AG5Graph20input_value_ref_slowENS_4data3ptrINS_4NodeEEENS_11AttributeIDEjPK15AGSwiftMetadataRhl + 394 
    at 27  AttributeGraph                      0x7ff81fd999f0     AGGraphGetValue + 217 
    at 28  SwiftUI                             0x1084b2347        get_witness_table 7SwiftUI4ViewRzlAA15ModifiedContentVyxAA30_EnvironmentKeyWritingModifierVyAA11FindContextVGGAaBHPxAaBHD1__AiA0cI0HPyHCHCTm + 18734 
    at 29  SwiftUI                             0x1084b2460        get_witness_table 7SwiftUI4ViewRzlAA15ModifiedContentVyxAA30_EnvironmentKeyWritingModifierVyAA11FindContextVGGAaBHPxAaBHD1__AiA0cI0HPyHCHCTm + 19015 
    at 30  SwiftUI                             0x107bc3ff3        block_destroy_helper.6215 + 63948 
    at 31  AttributeGraph                      0x7ff81fd7a1d6     _ZN2AG5Graph11UpdateStack6updateEv + 536 
    at 32  AttributeGraph                      0x7ff81fd7a9aa     _ZN2AG5Graph16update_attributeENS_4data3ptrINS_4NodeEEEj + 442 
    at 33  AttributeGraph                      0x7ff81fd8246d     _ZN2AG5Graph20input_value_ref_slowENS_4data3ptrINS_4NodeEEENS_11AttributeIDEjPK15AGSwiftMetadataRhl + 259 
    at 34  AttributeGraph                      0x7ff81fd99805     AGGraphGetInputValue + 241 
    at 35  SwiftUI                             0x107de728f        __swift_memcpy13_4 + 32739 
    at 36  SwiftUI                             0x108011aa8        __swift_memcpy38_4 + 167535 
    at 37  SwiftUI                             0x107fc0359        __swift_memcpy108_8 + 152193 
    at 38  SwiftUI                             0x107fc0211        __swift_memcpy108_8 + 151865 
    at 39  SwiftUI                             0x1087042e2        block_destroy_helper.13 + 81693 
    at 40  SwiftUI                             0x107ff13c9        __swift_memcpy38_4 + 34704 
    at 41  SwiftUI                             0x107b1e69f        __swift_memcpy90_8 + 2473671 
    at 42  SwiftUI                             0x107b8b174        objectdestroy.6475Tm + 32167 
    at 43  AttributeGraph                      0x7ff81fd7a1d6     _ZN2AG5Graph11UpdateStack6updateEv + 536 
    at 44  AttributeGraph                      0x7ff81fd7a9aa     _ZN2AG5Graph16update_attributeENS_4data3ptrINS_4NodeEEEj + 442 
    at 45  AttributeGraph                      0x7ff81fd824f4     _ZN2AG5Graph20input_value_ref_slowENS_4data3ptrINS_4NodeEEENS_11AttributeIDEjPK15AGSwiftMetadataRhl + 394 
    at 46  AttributeGraph                      0x7ff81fd99805     AGGraphGetInputValue + 241 
    at 47  SwiftUI                             0x1083289b6        get_witness_table 7SwiftUI4ViewRzlAA15ModifiedContentVyxAA12_FrameLayoutVGAaBHPxAaBHD1__AfA0C8ModifierHPyHCHCTm + 37017 
    at 48  SwiftUI                             0x107d80f18        __swift_memcpy80_8 + 85608 
    at 49  SwiftUI                             0x107d81b38        __swift_memcpy80_8 + 88712 
    at 50  SwiftUI                             0x10801183a        __swift_memcpy38_4 + 166913 
    at 51  SwiftUI                             0x1079893d5        __swift_memcpy90_8 + 814077 
    at 52  SwiftUI                             0x107b1cb92        __swift_memcpy90_8 + 2466746 
    at 53  SwiftUI                             0x107b4df5a        _swift_stdlib_malloc_size + 70511 
    at 54  AttributeGraph                      0x7ff81fd7a1d6     _ZN2AG5Graph11UpdateStack6updateEv + 536 
    at 55  AttributeGraph                      0x7ff81fd7a9aa     _ZN2AG5Graph16update_attributeENS_4data3ptrINS_4NodeEEEj + 442 
    at 56  AttributeGraph                      0x7ff81fd824f4     _ZN2AG5Graph20input_value_ref_slowENS_4data3ptrINS_4NodeEEENS_11AttributeIDEjPK15AGSwiftMetadataRhl + 394 
    at 57  AttributeGraph                      0x7ff81fd999f0     AGGraphGetValue + 217 
    at 58  SwiftUI                             0x108972390        __swift_memcpy53_8 + 382926 
    at 59  SwiftUI                             0x107b8e882        objectdestroy.6475Tm + 46261 
    at 60  AttributeGraph                      0x7ff81fd7a1d6     _ZN2AG5Graph11UpdateStack6updateEv + 536 
    at 61  AttributeGraph                      0x7ff81fd7a9aa     _ZN2AG5Graph16update_attributeENS_4data3ptrINS_4NodeEEEj + 442 
    at 62  AttributeGraph                      0x7ff81fd87377     _ZN2AG8Subgraph6updateEj + 909 
    at 63  SwiftUI                             0x107fef380        __swift_memcpy38_4 + 26439 
    at 64  SwiftUI                             0x1088ace43        get_witness_table 7SwiftUI19WidgetConfigurationRzAA13PreferenceKeyRd__r__lAA15ModifiedContentVyxAA01_E15WritingModifierVyqd__GGAaBHPxAaBHD1__AhA0cdJ0HPyHCHCTm + 92565 
    at 65  SwiftUI                             0x1088aa691        get_witness_table 7SwiftUI19WidgetConfigurationRzAA13PreferenceKeyRd__r__lAA15ModifiedContentVyxAA01_E15WritingModifierVyqd__GGAaBHPxAaBHD1__AhA0cdJ0HPyHCHCTm + 82403 
    at 66  SwiftUI                             0x108c6b01f        __swift_memcpy106_8 + 51271 
    at 67  SwiftUI                             0x108c6b065        __swift_memcpy106_8 + 51341 
    at 68  UIKitCore                           0x11162b59e        -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2304 
    at 69  QuartzCore                          0x7ff80898b02b     _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 525 
    at 70  QuartzCore                          0x7ff8089965b8     _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 64 
    at 71  QuartzCore                          0x7ff8088a7b0b     _ZN2CA7Context18commit_transactionEPNS_11TransactionEdPd + 625 
    at 72  QuartzCore                          0x7ff8088df69a     _ZN2CA11Transaction6commitEv + 734 
    at 73  UIKitCore                           0x111018aa3        __34-[UIApplication _firstCommitBlock]_block_invoke_2 + 33 
    at 74  CoreFoundation                      0x7ff800387dd8     __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 11 
    at 75  CoreFoundation                      0x7ff800387591     __CFRunLoopDoBlocks + 405 
    at 76  CoreFoundation                      0x7ff800381e37     __CFRunLoopRun + 947 
    at 77  CoreFoundation                      0x7ff8003816a6     CFRunLoopRunSpecific + 559 
    at 78  GraphicsServices                    0x7ff809cb1289     GSEventRunModal + 138 
    at 79  UIKitCore                           0x110ff8ad2        -[UIApplication _run] + 993 
    at 80  UIKitCore                           0x110ffd9ee        UIApplicationMain + 122 
    at 81  SwiftUI                             0x10897c666        __swift_memcpy93_8 + 11935 
    at 82  SwiftUI                             0x10897c513        __swift_memcpy93_8 + 11596 
    at 83  SwiftUI                             0x107fe07e8        __swift_memcpy195_8 + 12254 
    at 84  My application                      0x104e5d70d        $s14My_application6iOSAppV5$mainyyFZ + 29 (/Users/glebg/Desktop/projects/brain-chat/iosApp/iosApp/iOSApp.swift:<unknown>)
    at 85  My application                      0x104e5d798        main + 8 
    at 86  dyld                                0x1077f22be        0x0 + 4420739774 
    at 87  ???                                 0x1099d752d        0x0 + 4456281389

Expected behavior The hello-world example is running normally in the simulator.

Additional context It took e some time to set up all components required by kdoctor correctly, but in the end it showed a success message. I get the same error when trying to run the new Compose sample iOS app, without leveraging the template. At that time was using Xcode 13 and thought that upgrading it would remove the error, but it didn't help.

gleb-skobinsky commented 1 year ago

Running on a hardware device is successful. Will use this way for now.

kodeplateform commented 1 year ago

I'm facing same issue (on OSX Virtual Machine) . Just to know, you was using a physical mac device when you had this crash ?

gleb-skobinsky commented 1 year ago

Yes, I used Qemu to run MacOS from a Linux host. It is probably something related to Mac-specific graphics hardware acceleration. If I run desktop application in virtual machine, I get the warning that the renderer is running in software mode. It is probably related. If you try to connect an IPhone through USB, the build should work

okushnikov commented 4 weeks ago

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.