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

Long xml string seem cut in IOS #86

Closed
pamainville-clgx opened this issue Apr 27, 2022 · 13 comments
Closed

Long xml string seem cut in IOS #86

pamainville-clgx opened this issue Apr 27, 2022 · 13 comments
Labels
bug Something isn't working indev The issue is fixed/implemented in the dev branch inmaster The issue is fixed in the master branch

Comments

@pamainville-clgx
Copy link

I take my chance here

So, I have a very long XML string to decode, containing a list of object.

All is working fine in Android, decoding of the XML string work perfectly, what ever the length, but in IOS, it seem to have a problem and my investigation lead mo to something like the string would be cut, in IOS.

String of 7770 char work good
String of 8725 char give me

  • error = 1:8192 - name expected
    String of 8844 char give me

  • Expected text content or end tag, found: START_ELEMENT

Most so by just keeping the same exact structure in the XML list, same data, but adding just one element make it failed on IOS side!

I know this is not the best tool to be able to debug code look like this if this can help

@Suppress("UNCHECKED_CAST")
private val module = SerializersModule {}

private val xml = XML(module) {
    autoPolymorphic = true
    repairNamespaces = false
    unknownChildHandler = UnknownChildHandler { _, _, _, _, _ -> emptyList() }
}

val xmlEntity =  xml.decodeFromString(SomeStructure.serializer(), xmlStringTest)

I can try to make a better sample to provoque the bug

@pdvrieze
Copy link
Owner

The different platforms (by default) use different serializers/deserializers. The cross-platform one used for iOS is derived from the Android code, but you've probably found some sort of bug in buffer handling. You may note the number 8192 in the error, that is 8*1024 which is a buffer size used.

@pamainville-clgx
Copy link
Author

So, is there a way to fix this?

@pdvrieze
Copy link
Owner

The problem is a bug in the StringReader implementation. It has been pushed to the dev branch. The easiest workaround is to get your own reader (KtXmlReader) based upon an a fixed/alternative StringReader implementation. I'll see what I can do to release this as soon as possible.

@pdvrieze pdvrieze added bug Something isn't working indev The issue is fixed/implemented in the dev branch labels Apr 29, 2022
@pamainville-clgx
Copy link
Author

We're not in a hurray, but we would prefer if we do not have any platform special code to do :)

@rrenna
Copy link

rrenna commented May 3, 2022

I am also having this issue I believe. Hopefully a fix is up soon, thanks for your hard work.

@pdvrieze pdvrieze added the inmaster The issue is fixed in the master branch label May 4, 2022
@pdvrieze
Copy link
Owner

pdvrieze commented May 4, 2022

I'm now building 0.84.2, should release soon

@pamainville-clgx
Copy link
Author

GREAT

Thanks for your work!

@pamainville-clgx
Copy link
Author

Hmmm, got this error now with 0.84.2 when compiling IOS!

e: Compilation failed: Backend Internal error: Exception during IR lowering
File being compiled: /Users/runner/work/xmlutil/xmlutil/serialization/src/commonMain/kotlin/nl/adaptivity/xmlutil/serialization/annotations.kt
The root cause java.lang.AssertionError was thrown at: org.jetbrains.kotlin.backend.konan.lower.InitializersLowering$InitializersTransformer.lowerConstructors(InitializersLowering.kt:161)

@pdvrieze
Copy link
Owner

That probably is a compiler bug. Please try to clean and then build. I've noticed some issues with incremental compilation.

@rrenna
Copy link

rrenna commented May 11, 2022

I am getting the same error.

@rrenna
Copy link

rrenna commented May 11, 2022

Changed back to 0.84.1 and it builds, cleaned project and tried again, same result - the above error.

@rrenna
Copy link

rrenna commented May 11, 2022

Upon further investigation it looks like it's failing to find 0.84.2, I looked at the Maven url and the artifact isn't there - is that normal? https://s01.oss.sonatype.org/content/repositories/snapshots/io/github/pdvrieze/xmlutil/core/

@pdvrieze
Copy link
Owner

That is a snapshot repository. I didn't create a snapshot, only a proper release (on mavencentral). It is here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working indev The issue is fixed/implemented in the dev branch inmaster The issue is fixed in the master branch
Projects
None yet
Development

No branches or pull requests

3 participants