What steps will reproduce the problem?
1. Make a call to an RPC method which returns a large amount (>1kB) of data
such as 'contactsGet' or 'smsGetMessages'.
2.
3.
What is the expected output? What do you see instead?
The decoded JSON should be returned from the method call. Instead, the terminal
shows some PHP notices on like 54/55 of Android.php about accessing undefined
properties. A number of subsequent calls will return an empty response (id,
result and error all null).
What version of the product are you using? On what operating system?
Whichever version sl4a automatically installed when I added it through the
interpreters menu. Running on Android 4.0.1 on Galaxy Nexus.
Please provide any additional information below.
The issue arises because the socket_read call on line 49 is only reading 1kB of
data from the socket. If the returned response is greater than 1kB then an
incomplete JSON object is returned, and decoding fails (resulting in the
notices). Subsequent requests fail because of the data remaining in the socket
which causes subsequent reads to contain another partial JSON object.
The simplest patch, and the one that fixed the issue for me, was simply to up
the amount read in the single socket_read call. I upped it from 1024 to 1048576
(1MB). The 'proper' fix would be to loop until socket_read returns a blank
string (which, as per the PHP manual page, signifies no more data to be read).
Original issue reported on code.google.com by
nuclear...@gmail.comon 19 Feb 2012 at 4:41