Closed MichalKlusak closed 1 year ago
Welcome and thanks for contributing! Make sure to leave a detailed explanation of the issue.
I was able to reproduce the issue. I'm not positive about the cause, but it seemed to be an incorrect function call. It was resolved after the changes made in the following commit where I removed the AndroidParceler
class: https://github.com/chRyNaN/serialization-parcelable/commit/92fd90cc5f6aa9365c1e306592f8b79c7dde11ac. I will try and write some tests to make sure that this issue doesn't occur again. The fix will be released in the next version.
The issue has to do with the Parcel(ByteArray)
constructor function implementation for the Android target. The decodeFromParcel
function was updated previously to get the parcel.toByteArray()
from the parcel
parameter and create a new Parcel
using that constructor function. Then that Parcel was decoded with a ParcelDecoder
. This was added to help some issue with the ByteArrayParcel
implementation for other platforms, but it seems that it broke the Android usage. I will investigate further and ensure that both implementations work.
The issue had to do with the Android implementation of the Parcel(ByteArray)
calling setDataPosition(0)
and the above mentioned use of creating a new Parcel from the provided parcel in the Parcelable.decodeFromParcel
function. The Parcelable.encodeToBundle/Parcelable.decodeFromBundle
have to internally manage a size and magic numbers set inside the android.os.Parcel class. Because of this, the size should have been set to 8
(two four byte int values were set). Instead of hardcoding this, since it is TBD which component should be responsible for setting that, I think removing the wrapper creation of a new parcel in the decodeFromParcel
function is the solution and seems to work. However, we should be on the lookout for issues on other Kotlin targets.
Resolved with release 0.6.0 (10)
: https://github.com/chRyNaN/serialization-parcelable/releases/tag/0.6.0
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:
1)
Result behavior Params(false)
Expected behavior Params(true)
2)
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