Coder Social home page Coder Social logo

Comments (5)

cfdrake avatar cfdrake commented on June 11, 2024

Hello!

I've been probing more into this recently and think I have found the root issue.

Here is a minimal test case that will work on iOS 16 and fail on iOS 17 beta, calling into j2objc's JRE emulation:

func testDecodeStream() {
    let testString = "{testtest}"
    let data = testString.data(using: .utf8)
    let byteArray = IOSByteArray(nsData: data)
    let stream: JavaIoInputStream = JavaIoByteArrayInputStream(byteArray: byteArray)
    let reader: JavaIoReader = JavaIoInputStreamReader(javaIoInputStream: stream, with: "UTF-8")
        
    print("ready? \(reader.ready())")
    while (reader.ready()) {
        let byte = reader.read()
        print(byte)
        print("--")
    }
}

On iOS 16 I see that the reader indicates it is ready, the stream has 10 characters available to read, and the loop executes printing each character out line by line.

With no changes, on iOS 17 beta I see that the reader indicates it is ready, the first byte is read, but the loop only executes once printing 65533.

Based on what I've been reading, GSON is using these functions/classes internally for parsing JSON responses, which is why we're seeing the failures in our app.

from j2objc.

cfdrake avatar cfdrake commented on June 11, 2024

Just a note I've found that writing to a stream fails on iOS 17 as well. See the test code here:

private func testWriteSteam() {
        let stream = JavaIoByteArrayOutputStream()
        let writer = JavaIoBufferedWriter(javaIoWriter: JavaIoOutputStreamWriter(javaIoOutputStream: stream, with: "UTF-8"))
        
        let testString = "{testtest}"
        let byteArray = IOSCharArray(nsString: testString)!
        
        writer.write(with: byteArray, with: 0, with: byteArray.length())
        writer.flush()
        
        print(stream)
        print("DONE!")
    }

On iOS 16 I see "{testtest}" and on iOS 17 it just prints an empty line.

from j2objc.

litstrong avatar litstrong commented on June 11, 2024

Hi Cotlin, I apologize for my late reply. Your finding looks real, and thanks for your report and test cases!

The team is sort of under-staffed at the moment, so the response might be a bit slow. But this one is indeed import to us, and we'll look into it.

Thanks again. :)

from j2objc.

cfdrake avatar cfdrake commented on June 11, 2024

@litstrong Great, thanks for confirming.

Just a note I've done some further testing on this and interestingly it only appears to be an issue with the simulator, not physical devices running the beta.

from j2objc.

litstrong avatar litstrong commented on June 11, 2024

Hi Cotlin,

I tested your code snippet under Xcode 15 beta 8 (simulator), and it seems running well.

from j2objc.

Related Issues (20)

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.