-
Notifications
You must be signed in to change notification settings - Fork 636
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: Could not cast value of type 'ASLMPKMapAsNSDictionary' to 'ASLMPKotlinx_serialization_jsonJsonElement' #2919
Comments
The types can be found here: https://github.com/nuke-dash/JsonObject-Crash/blob/main/appsharedlogic/shared/src/commonMain/kotlin/com/company/app/sharedlogic/models/ecc/Alternative.kt Can you provide a stacktrace, to identify what happens, as obviously an NSLMPKMapAsNSDictionary (which appears to be an adapter from Kotlin's map type to an ios NSDictionary) is not a json element. |
Yes, here is the stacktrace and a screenshot of it crashing in Xcode.
|
I think you have the wrong thread for the stacktrace, but the screenshot is somewhat helpful (I don't have a mac). It seems that creating an What I don't know is what the " The best next step is to introspect the structure returned from the accessor using the debugger. |
@pdvrieze thanks for the support so far! The stacktrace I copied is the main thread and the same thread as you can see in the screenshot on the left side. The "String(" is just a basic way to log a variable. Trying to debug the property by printing it in the console doesn't work. Trying to assign the queryDefinition directly to a var for better inspection also doesn't works and results in a crash immediatly. |
Something really strange is going on here. Some really strange things are going on here. There is no obvious issue. Probably you want to have a look at various bits. Try to just deserialize to I actually suspect there might be an issue with the coroutines/async code. In particular you are using swift await with a Kotlin suspend function (if it is even supported it is very new functionality that may be broken). |
You need some extra config before inspecting your kt objects, try following the instruction by importing a lldb script, make sure you are importing the correct version from your local kotlin-native distrubution, and then check what types exactlly the properties are. |
It looks like the same issue as #759 and JetBrains/kotlin-native#3991. The problem is that As a workaround, you can write all JsonElement-related functions in Kotlin and use Swift only to call these functions. It is far from ideal, but this is how Kotlin/Swift interop is currently designed. |
Issue was moved here: https://youtrack.jetbrains.com/issue/KT-48079 |
Describe the bug
An object of type JsonObject cannot be used in tvOS.
When trying to access it, inspect it, debug it, it causes the compiled library to crash.
The class containing the property
Creating the object from json
Using it in swift
Could not cast value of type 'ASLMPKMapAsNSDictionary' (0x1040305f0) to 'ASLMPKotlinx_serialization_jsonJsonElement' (0x104030198).
To Reproduce
A sample project can be found here showcasing the crash with precompiled tvOS/iOS simulator libraries.
Checkout the project, open the xcodeproj and run it.
A README is also included in the sampe project with more details.
https://github.com/nuke-dash/JsonObject-Crash
Expected behavior
To not crash.
To allow it to be printed, used.
Environment
The text was updated successfully, but these errors were encountered: