WL 6.0.0.1
I'm working with files, sending and receiving them between the backend and the worklight app.
I'm using adapters and custom phonegap plugins developed by me to send and receive files.
The issue I'm having is that with iPad I can not work with files > 5mg and in Android with API 2.2 (so not using android:largeHeap="true") I can not work with files > 3mg. In case of using largeHeap = true I can not work with files > 5mg
With bigger file sizes I get out of memory.
What I'm doing is from the app request a file from the backend using an adapter, the adapter using java reads the file in byte[] and code it to a base64 String that is returned, then the app pass this base64 string to a phonegap plugin and the plugin decode it to a byte[] and write it to the disk.
The adapter side is working after setting a heap size of 1024mg, the app size throws out of memory exceptions.
For sending files I have the issue with my plugin, coding the byte[] to base64 String, I understand it needs to make a copy of the data so it multiply *2 the needed memory, any was it sounds strange. I will try to debug the Base64 code...
For receiving I get the Out Of Memory after calling the adapter and before the adapter callbacks.
So:
WL.Logger.debug('Invoking Load File Adapter');
WL.Client.invokeProcedure(invocationData, invocationOptions );
function successLoadFile(ret)
{
WL.Logger.debug('Into Load File adapter success');
I see the trace "Invoking Load File Adapter" but I do not see the trace "Into Load File adapter success" nor "Error" one.
The log is:
E/dalvikvm-heap(11623): Out of memory on a 17994284-byte allocation.
I/dalvikvm(11623): "WebViewCoreThread" prio=5 tid=11 RUNNABLE
I/dalvikvm(11623): | group="main" sCount=0 dsCount=0 obj=0x41a7ed28 self=0x583d2558
I/dalvikvm(11623): | sysTid=11636 nice=0 sched=0/0 cgrp=[no-cpu-subsys] handle=1368554752
I/dalvikvm(11623): | schedstat=( 173239349436 4901367062 38904 ) utm=16976 stm=347 core=1
I/dalvikvm(11623): at java.lang.AbstractStringBuilder.enlargeBuffer(AbstractStringBuilder.java:~94)
I/dalvikvm(11623): at java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:162)
I/dalvikvm(11623): at java.lang.StringBuilder.append(StringBuilder.java:311)
I/dalvikvm(11623): at org.json.JSONTokener.nextString(JSONTokener.java:224)
I/dalvikvm(11623): at org.json.JSONTokener.nextValue(JSONTokener.java:107)
I/dalvikvm(11623): at org.json.JSONTokener.readArray(JSONTokener.java:430)
I/dalvikvm(11623): at org.json.JSONTokener.nextValue(JSONTokener.java:103)
I/dalvikvm(11623): at org.json.JSONArray.<init>(JSONArray.java:87)
I/dalvikvm(11623): at org.json.JSONArray.<init>(JSONArray.java:103)
I/dalvikvm(11623): at org.apache.cordova.api.CordovaPlugin.execute(CordovaPlugin.java:65)
I/dalvikvm(11623): at org.apache.cordova.api.PluginManager.exec(PluginManager.java:224)
I/dalvikvm(11623): at org.apache.cordova.ExposedJsApi.exec(ExposedJsApi.java:44)
I/dalvikvm(11623): at android.webkit.JWebCoreJavaBridge.nativeServiceFuncPtrQueue(Native Method)
I/dalvikvm(11623): at android.webkit.JWebCoreJavaBridge.nativeServiceFuncPtrQueue(Native Method)
I/dalvikvm(11623): at android.webkit.JWebCoreJavaBridge.handleMessage(JWebCoreJavaBridge.java:113)
I/dalvikvm(11623): at android.os.Handler.dispatchMessage(Handler.java:99)
I/dalvikvm(11623): at android.os.Looper.loop(Looper.java:137)
I/dalvikvm(11623): at android.webkit.WebViewCore$WebCoreThread.run(WebViewCore.java:1067)
I/dalvikvm(11623): at java.lang.Thread.run(Thread.java:856)
E/Mapfre(11623): [http://192.168.1.39:10080/Mapfre/apps/services/api/Mapfre/android/query] exception. Error: Error calling method on NPObject.
I have tried with .txt .ppt and .pdf.
Thank you.