Bombus - mobile Jabber client
Sources: http://bombus-im.org/wiki/bombus/svn
!!! ВНИМАНИЕ !!! Убедительная просьба перед занесением багрепорта ознакомиться с правилами. Правильно оформленный отчёт об ошибке - залог быстрого её исправления. Спасибо!
FS#858 — Problematic InputStream.available() on some Samsung devices (patch)
Открыто Krzysztof Kotlenga (pocek_) - Saturday, 09 August 2008, 10:51 GMT+1
|
ПодробностиOn some Samsung devices[1] connection hangs on “Opening stream”, sometimes it throws “java.io.InterruptedIOException: available was failed”, sometimes it just hangs. Problem relies in Utf8IOStream.read() where InputStream.available() is used. According to InputStream.available() description this method always returns 0, so I don’t really understand how it’s supposed to work anyway (and apparently it does, at least on most devices). I see it could work when called on ZInputStream which simply returns bufsize (512), but it’s there only after Utf8IOStream.setStreamCompression() is called. I have made a workaround by removing 512 bytes buffer and directly coupling reader with parser: bombus-direct-parsing.diff - there’s no need to call available() and it works. [1]
|
FYI, ZInputStream also polls InputStream.available() (see ZInputStream.java:95)
Actually, InputStream is absctract class and can’t be used directly to create InputStream object. Most phones that i tested has overriden available() method in InputStream object provided by StreamConnection.openInputStream() and works fine.
If ZLib compression (using available polling as said before) works fine with your patch, then problem may exists only when reading very first data from socket.
I won’t remove polling socket because of two reasons:
I suppose another way to fix this problem - disabling available() polling just for Samsung
Thanks for your explanation. With ZLib compression enabled I get “Exception in parser: com.jcraft.jzlib.ZStreamException: inflating: unknown compression method” on emulator, didn’t test on the phone. I was unable to track down why this happens; maybe it’s something with reading single byte in ZInputStream.read().
I did some tests using modified NetworkDemo and found that:
Better patch: bombus-blocking2.diff
* except available() being still there but I’d like to solve that threading issue first
unfortunately blocking reading will break compatibility with motorola devices - read(byte[], int, int) sometimes hangs when bombus was backgrounded. so available() should still be used at least for motorola