Android Question Deserializing slow

gerardusmercator

New Member
Licensed User
Longtime User
Hi all,

first of all, I have to say that I am amazed at how easy it is to get things done with B4A and B4J.
I started playing with the idea of porting old data collection project from Windows CE to Android, and I've got a raw app in hours.
I have a B4J server that connects to a Firebird DB, exposing services. Then I made a very simple app for Android that talks to the server to get data and send back results.
I took the following tutorial as an example: http://www.b4x.com/android/forum/threads/server-send-and-receive-objects.37206/
All is working fine so far, but reading a list of objects from a stream returned by the server is quite slow.
While the data transfer is fast, it takes up to three minutes to "deserialize" a list of 2.800 objects on the client side.
I use the following function to read the objects from the stream:

B4X:
Sub ReadObject (In As InputStream) As Object
  Dim out As OutputStream
  out.InitializeToBytesArray(0)
  File.Copy2(In, out)
  Dim raf2 As RandomAccessFile
  raf2.Initialize3(out.ToBytesArray, False)
  Dim res As Object = raf2.ReadObject(0)
  raf2.Close
  Return res
End Sub

Called like this:

B4X:
Sub JobDone(j As HttpJob)
   If j.Success Then
     tt2 = DateTime.Now
     LListaRutes  = ReadObject(j.GetInputStream)
     tt3 = DateTime.Now
     'Log(LListaRutes)
   Else
     Log("Error: " & j.ErrorMessage)
   End If
   ProgressDialogHide 
   j.Release
   tt3 = DateTime.Now
End Sub

Does anyone have an idea how to speed up the process?

Edit: I forgot to add that I'm running tha Android app in the ADV emulator.

Regards,

Gerard.
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
Try it with a real device. The emulator is REALLY SLOW...
 
Upvote 0

gerardusmercator

New Member
Licensed User
Longtime User
Hi Manfred.
You where right. I tested it with a phone (Samsung SIII Mini) with a WIFI connection and it's a lot faster. It took 3 minutes and now it's done in 20 seconds!
Thanks a lot, have a nice weekend.

Gerard.
 
Upvote 0
Top