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

Sample crashes with Flow serialization issue #654

Closed
swankjesse opened this issue Aug 15, 2022 · 5 comments
Closed

Sample crashes with Flow serialization issue #654

swankjesse opened this issue Aug 15, 2022 · 5 comments

Comments

@swankjesse
Copy link
Contributor

I’m running the emoji search sample and it’s bitrotted.

2022-08-15 12:46:38.358 6126-6151/com.example.zipline.emojisearch.debug E/Zipline: java.lang.Exception: SerializationException: Class 'ChannelFlowBuilder' is not registered for polymorphic serialization in the scope of 'Flow'.
    Mark the base class as 'sealed' or register the serializer explicitly.
        at captureStack (../../../../../runtime/coreRuntime.kt:86)
        at SerializationException_init_$Create$_0 (kotlinx-serialization-kotlinx-serialization-core-js-ir.js)
        at throwSubtypeNotRegistered_0 (../../../../../Z:/BuildAgent/work/b2fef8360e1bcf3d/core/commonMain/src/kotlinx/serialization/internal/AbstractPolymorphicSerializer.kt:102)
        at throwSubtypeNotRegistered (../../../../../Z:/BuildAgent/work/b2fef8360e1bcf3d/core/commonMain/src/kotlinx/serialization/internal/AbstractPolymorphicSerializer.kt:113)
        at findPolymorphicSerializer (../../../../../Z:/BuildAgent/work/b2fef8360e1bcf3d/core/commonMain/src/kotlinx/serialization/PolymorphicSerializer.kt:109)
        at <anonymous> (../../../../../Z:/BuildAgent/work/b2fef8360e1bcf3d/core/commonMain/src/kotlinx/serialization/internal/AbstractPolymorphicSerializer.kt:32)
        at <anonymous> (../../../../../Polymorphic.kt:89)
        at <anonymous> (../../../../../Z:/BuildAgent/work/b2fef8360e1bcf3d/core/commonMain/src/kotlinx/serialization/encoding/AbstractEncoder.kt:80)
        at <anonymous> (../../../../../commonMainSources/libraries/stdlib/src/kotlin/util/Preconditions.kt:287)
        at <anonymous> (zipline-root-zipline.js)
        at <anonymous> (../../../../../Polymorphic.kt:89)
        at <anonymous> (../../../../../Z:/BuildAgent/work/b2fef8360e1bcf3d/core/commonMain/src/kotlinx/serialization/encoding/AbstractEncoder.kt:80)
        at <anonymous> (../../../../../Z:/BuildAgent/work/b2fef8360e1bcf3d/core/commonMain/src/kotlinx/serialization/encoding/Encoding.kt:287)
        at <anonymous> (zipline-root-zipline.js)
        at <anonymous> (../../../../../Polymorphic.kt:89)
        at encodeToDynamic_0 (../../../../../DynamicEncoders.kt:42)
        at encodeToDynamic (../../../../../Dynamics.kt)
        at encodeToStringFast (../../../../../jsonJs.kt)
        at <anonymous> (../../../../../CallCodec.kt:56)
        at <anonymous> (../../../../../OutboundCallHandler.kt:52)
        at <anonymous> (../../../../../SuspendCallback.kt)
        at <anonymous> (zipline-root-zipline.js)
        at <anonymous> (../../../../../InboundService.kt:713)
        at <anonymous> (../../../../../InboundService.kt)
        at l (zipline-root-zipline.js)
        at <anonymous> (../../../../../src/kotlin/coroutines_13/IntrinsicsJs.kt:163)
        at <anonymous> (../../../../../src/kotlin/coroutines_13/CoroutineImpl.kt:55)
        at <anonymous> (kotlin-kotlin-stdlib-js-ir.js)
        at <anonymous> (../../../../../DispatchedTask.kt:10131)
        at <anonymous> (../../../../../commonMainSources/libraries/stdlib/src/kotlin/util/Standard.kt:153)
        at <anonymous> (../../../../../JSDispatcher.kt:19)
        at apply (native)
        at <anonymous> (../../../../../GlobalBridge.kt:70)
        at <anonymous> (../../../../../platform.kt)
        at <anonymous> (zipline-root-zipline.js)
        at <anonymous> (../../../../../InboundService.kt:835)
        at <anonymous> (../../../../../Endpoint.kt:79)
        at <anonymous> (zipline-root-zipline.js)
        at <anonymous> (../../../../../GlobalBridge.kt)
        at <anonymous> (zipline-root-zipline.js)
        at app.cash.zipline.internal.JsPlatform$Companion$Adapter$GeneratedOutboundService.runJob(platform.kt:37)
        at app.cash.zipline.internal.CoroutineEventLoop$DelayedJob$run$1.invokeSuspend(CoroutineEventLoop.kt:59)
        at app.cash.zipline.internal.CoroutineEventLoop$DelayedJob$run$1.invoke(Unknown Source:8)
        at app.cash.zipline.internal.CoroutineEventLoop$DelayedJob$run$1.invoke(Unknown Source:4)
        at kotlinx.coroutines.intrinsics.UndispatchedKt.startCoroutineUndispatched(Undispatched.kt:55)
        at kotlinx.coroutines.BuildersKt__Builders_commonKt.startCoroutineImpl(Builders.common.kt:198)
        at kotlinx.coroutines.BuildersKt.startCoroutineImpl(Unknown Source:1)
        at kotlinx.coroutines.AbstractCoroutine.start(AbstractCoroutine.kt:134)
        at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch(Builders.common.kt:56)
        at kotlinx.coroutines.BuildersKt.launch(Unknown Source:1)
2022-08-15 12:46:38.358 6126-6151/com.example.zipline.emojisearch.debug E/Zipline:     at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch$default(Builders.common.kt:47)
        at kotlinx.coroutines.BuildersKt.launch$default(Unknown Source:1)
        at app.cash.zipline.internal.CoroutineEventLoop$DelayedJob.run(CoroutineEventLoop.kt:57)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:920)
@JakeWharton
Copy link
Member

Once fixed, if you write a quick Espresso test I'll set up the CI for it.

@swankjesse
Copy link
Contributor Author

I think the core issue is we have special serialization support for Flow, and we have other special serialization support for the result of a suspend fun, but we don’t have anything for the combination of these features.

The frustrating part here is that Kotlin serialization doesn’t compose the way I want it to for type parameters. In particular I can’t find a way to mark the type parameter as contextual. I can probably find a work around but ugh.

@JakeWharton
Copy link
Member

Hmm. There should (almost) never be a reason to have a suspend function that returns a Flow as the async operation can be moved into the flow itself to occur upon collection.

Should we just ban it?

@swankjesse
Copy link
Contributor Author

Good idea on the immediate problem. I think I’m still in a bad place with the way the serialization of types composes.

@swankjesse
Copy link
Contributor Author

Fix will be the same as #602

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants