Git Product home page Git Product logo

serialization-parcelable's Issues

Parcelize serializable data is broken

Describe the bug
When I'm trying to transfer Serializable data through Bundle, I use methods putParcelable and getParcelable to parcelize it but the result data is broken.

To Reproduce
Params:

@Serializable
data class Params(val intro: Boolean)
val params = Params(true)
val bundle = Bundle()
bundle.putParcelable("key", params)
bundle.getParcelable("key")

Result behavior
Params(false)

Expected behavior
Params(true)

val params = Params(false)
val bundle = Bundle()
bundle.putParcelable("key", params)
bundle.getParcelable("key")

Result behavior
null

Expected behavior
Params(false)

Additional context
Serialization-parcelable - 0.5.1 (version 0.5.0 works fine)
Kotlin - 1.7.20
Kotlin-serialization - 1.4.1

NPE in ByteArrayParcel init

The init block in ByteArrayParcel throws an NPE because data is not set when setDataFromByteArray runs.

I'm not sure if this is caused by a compiler change in Kotlin 1.7, because ordinarily you'd get a compiler diagnostic like "data is not initialized".

The easiest fix would be to move the init { } block below where the data property is initialized.

Stacktrace:

Cannot invoke "java.util.List.clear()" because "this.data" is null
java.lang.NullPointerException: Cannot invoke "java.util.List.clear()" because "this.data" is null
	at com.chrynan.parcelable.core.ByteArrayParcel.setDataFromByteArray(ByteArrayParcel.kt:188)
	at com.chrynan.parcelable.core.ByteArrayParcel.<init>(ByteArrayParcel.kt:17)
	at com.chrynan.parcelable.core.ByteArrayParcel.<init>(ByteArrayParcel.kt:14)
	at com.chrynan.parcelable.core.JvmParcelKt.Parcel(JvmParcel.kt:3)

Unmarshalling unknown type code 7340148 at offset 8

Describe the bug
There is a bug in library that happens only on Pixel devices.

Fatal Exception: java.lang.RuntimeException: Parcel android.os.Parcel@52c801c: Unmarshalling unknown type code 6357038 at offset 8
at android.os.Parcel.readValue(Parcel.java:3305)
at android.os.Parcel.readArrayMapInternal(Parcel.java:3623)
at android.os.BaseBundle.initializeFromParcelLocked(BaseBundle.java:292)
at android.os.BaseBundle.unparcel(BaseBundle.java:236)
at android.os.Bundle.filterValues(Bundle.java:395)
at android.os.Bundle.filterValues(Bundle.java:405)
at android.content.Intent.removeUnsafeExtras(Intent.java:8859)
at android.app.ActivityThread.handleRequestAssistContextExtras(ActivityThread.java:3890)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2171)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7839)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)

I can't reproduce it, but we have a lot of bugs in firebase crashlytics. With no specific case, any screen with your parcelable between intents/fragments inside intent is potential threat.

Smartphone (please complete the following information):

  • Device: any Pixel
  • OS: android 12

Additional context
It is happening with version 0.3.1, I have simultaneously upgraded to 0.4.1 and will give feedback whether it still happens.

Decoding nullable types from Bundle

Describe the bug

The Parcelable.decodeFromBundle() functions impose an upper bound of <T : Any> on the value type, which doesn't mirror the decodeFromByteArray and decodeFromParcel functions.

I'm optimistic that the : Any bound could simply be removed, as it's the serializer's job to encode/decode null and not-null marks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.