Problem
Summary: Uploading files larger than appx. 10 MB on older Android devices results in java.lang.OutOfMemoryError either called within httpclient.onerror, or as an uncaught exception viewable in LogCat before upload even starts.
Expected behavior: Being able to upload the attached 50 MB file with no errors. Perhaps it doesn't upload in chunks?
Actual behavior: httpclient.onerror is called with e.error: java.lang.OutOfMemoryError, or uncaught exception, depending on how much RAM device has.
Test findings
I've done a lot of testing to narrow this down.
For simulators I exclusively used intel x86 images.
I've tested exclusively with no apps running in the background.
Here's my findings:
OK: No error - the file is uploaded OK.
Error 1: Out of memory error in httpclient.onerror
Error 2: Uncaught exception, error in LogCat (generel output at bottom of this post)
Android 4.1.2
{color:red}- Simulator, RAM: 200 MB RAM, Error 2
- Simulator, RAM: 768 MB RAM, Error 1
- Samsung Galaxy S3, RAM: 2GB, Error 1{color}
Android 4.2.2
{color:green}- Simulator, RAM: 768 MB RAM, OK{color}
{color:red}- Simulator, RAM: 600 MB RAM, Error 1
- Simulator, RAM: 200/400 MB RAM, Error 2{color}
Android 4.3.1 or 4.3
{color:red}- Galaxy Nexus, Android 4.3, RAM: 1GB, Error 2
- Samsung Galaxy S3, Android 4.3, RAM: 2GB, Error 1
- Simulator, RAM: 600 MB, Error 1
- Simulator, RAM: 400 MB, Error 2{color}
Android 4.4.2
{color:red}- Simulator, RAM: 400 MB, Error 1
- Simulator, RAM: 200 MB, emulator hangs completely on splash screen of app when launched{color}
{color:green}- Simulator, RAM: 768 MB, OK{color}
Android 5.0.1
{color:green}- Simulator, RAM: 400 MB, OK
- Simulator, RAM: 200 MB, OK{color}
Android 6.0
{color:green}- Simulator, Android 6.0, RAM: 200 MB, OK{color}
Android 7
{color:green}- OnePlus 3, Android 7, RAM: 6 GB RAM, OK
- Simulator, Android 7, RAM: 768 MB RAM, OK
- Simulator, Android 7, RAM: 200 MB RAM, OK{color}
Test conclusion
On Android SDK versions below 5, for devices with little RAM, all uploads will fail with out of memory errors.
Possible fix suggestion
Perhaps detect Android versions below 5 when sending large files via httpclient, and upload those files in chunks instead of reading it all to memory.
If httpclient is already using chunked uploads, maybe decrease chunk sizes.
Test case
Compiled APK here:
https://bitfabrikken.dk/testapp.apk
Test file for downloading here:
https://bitfabrikken.dk/50mb_file.mp4 (just a linux dd-generated file with lots of dots)
var win = Ti.UI.createWindow({
backgroundColor: "black",
});
win.addEventListener('open',function listener(){
win.removeEventListener('open', listener);
testupload();
});
var progressLabel = Ti.UI.createLabel({
text: "0%",
color: "white",
font: { fontSize: 50},
bottom: 10,
left: 10,
});
win.add(progressLabel);
win.open();
function testupload(){
//any resolvable hostname will do for this test, but I setup a simple php file that simply prints "OK" on any request
var url = "https://bitfabrikken.dk/testupload.php";
var xhr = Ti.Network.createHTTPClient({
//various parameters below I've tried that don't work
//enableKeepAlive: false,
//keepAlive: false,
//autoEncodeUrl: false,
//validatesSecureCertificate: true,
//timeout: 10000000,
});
xhr.onsendstream = function(e){
progressLabel.text = parseInt(e.progress * 100)+"%";
};
xhr.onerror = function(e){
console.log("xhr.onerror:");
console.log(e);
alert(JSON.stringify(e));
};
xhr.onload = function(e){
//this.responseText should be "OK"
alert("SUCCESS!");
console.log("SUCCESS!");
};
xhr.open("POST", url);
var file = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, "50mb_file.mp4");
if (!file.exists()){
alert("file not found");
return;
}
//various different headers I've tried, same error
//xhr.setRequestHeader("Connection","Close");
//xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
//xhr.setRequestHeader("enctype", "multipart/form-data");
console.log("SENDING FILE, size: "+(file.size/1024/1024)+" MB");
xhr.send({
file: file
});
}
Logs
httpclient.onerror is called with the following:
{
"code": -1,
"source": {
"responseText": "",
"location": "http://website.com/",
"status": 0,
"domain": null,
"readyState": 1,
"tlsVersion": 3,
"connectionType": "POST",
"validatesSecureCertificate": true,
"statusText": null,
"username": null,
"password": null,
"allResponseHeaders": "",
"responseXML": null,
"responseData": null,
"autoRedirect": true,
"apiName": "Ti.Network.HTTPClient",
"autoEncodeUrl": true,
"connected": false,
"bubbleParent": true,
"_events": {
"disposehandle": {}
}
},
"error": "java.lang.OutOfMemoryError",
"success": false
}
Build log
2016-12-20T09:36:55.012Z | TRACE | set environment to {"registry":"https://software.appcelerator.com","security":"https://security.appcelerator.com","baseurl":"https://platform.appcelerator.com"}
2016-12-20T09:36:55.013Z | TRACE | checking credentials for existing session
2016-12-20T09:36:55.236Z | TRACE | Attempting to load session info from config file
2016-12-20T09:36:55.240Z | TRACE | check if session is invalidated
2016-12-20T09:36:56.102Z | TRACE | registry result 200 application/json undefined undefined false undefined
2016-12-20T09:36:56.130Z | TRACE | registry returned { expiry: 1482831414645 }
2016-12-20T09:36:56.130Z | TRACE | refresh session expiry to: 1482831414645
2016-12-20T09:36:56.133Z | TRACE | session expiry 1482831414645 false
2016-12-20T09:36:56.134Z | TRACE | Arrow Cloud config file: C:\Users\kronholm\.acs
2016-12-20T09:36:56.135Z | TRACE | found Arrow Cloud login { mid: 'CENSORED',
publishPort: 443,
publishHost: 'https://admin.cloudapp-enterprise.appcelerator.com',
username: 'CENSORED',
cookie: [ 'connect.sid=CENSORED; Path=/; Expires=Tue, 03 Jan 2017 07:45:16 GMT; HttpOnly' ],
defaultEP:
{ publishHost: 'https://admin.cloudapp-enterprise.appcelerator.com',
publishPort: 443 } } , checking nodeACSEndpoint= https://admin.cloudapp-enterprise.appcelerator.com
2016-12-20T09:36:56.137Z | TRACE | Arrow Cloud cookie expiry [ 1483429516000 ]
2016-12-20T09:36:56.137Z | TRACE | session already loaded in opts.session
2016-12-20T09:36:56.139Z | TRACE | getCredentials() session:
{
"ipaddress": "10.0.0.6",
"username": "CENSORED",
"password": "<OMITTED>",
"session": "<OMITTED>",
"nonce": "<OMITTED>",
"environment": {
"name": "production",
"isProduction": true,
"acsBaseUrl": "https://api.cloud.appcelerator.com",
"acsAuthBaseUrl": "https://secure-identity.cloud.appcelerator.com",
"nodeACSEndpoint": "https://admin.cloudapp-enterprise.appcelerator.com"
},
"token": "<OMITTED>",
"fingerprint": "CENSORED",
"fingerprint_description": "Windows Machine ID: CENSORED",
"org_id": 100008383,
"expiry": 1482831414645
}
2016-12-20T09:36:56.140Z | TRACE | loading plugins for command "run"
2016-12-20T09:36:56.181Z | TRACE | run search paths:
[
"C:\\Users\\kronholm\\.appcelerator\\install\\6.1.0\\package",
"C:\\Users\\kronholm\\.appcelerator\\install\\6.1.0\\package\\node_modules",
"C:\\Windows\\system32\\node_modules",
"C:\\Windows\\node_modules",
"C:\\node_modules",
"C:\\Users\\kronholm\\.appcelerator\\.npm\\lib\\node_modules"
]
2016-12-20T09:36:56.182Z | DEBUG | [PLUGIN-LOAD] 0ms C:\Users\kronholm\.appcelerator\install\6.1.0\package\appc.js
2016-12-20T09:36:56.407Z | DEBUG | [PLUGIN-LOAD] 224ms C:\Users\kronholm\.appcelerator\install\6.1.0\package\node_modules\appc-cli-titanium\appc.js
2016-12-20T09:36:56.407Z | DEBUG | run plugin: C:\Users\kronholm\.appcelerator\install\6.1.0\package\node_modules\appc-cli-titanium
2016-12-20T09:36:56.408Z | DEBUG | [PLUGIN-LOAD] 0ms C:\Users\kronholm\.appcelerator\install\6.1.0\package\node_modules\arrow\appc.js
2016-12-20T09:36:56.410Z | DEBUG | run plugin: C:\Users\kronholm\.appcelerator\install\6.1.0\package\node_modules\arrow
2016-12-20T09:36:56.413Z | TRACE | plugin "arrow" failed its "when" function check, skipping...
2016-12-20T09:36:56.414Z | TRACE | loading plugin "titanium" for command "run" CLI options via function
2016-12-20T09:36:56.414Z | TRACE | loading plugin "titanium" for command "run" CLI options via array
2016-12-20T09:36:56.415Z | TRACE | executing command "run" with the following plugins:
["titanium"]
2016-12-20T09:36:56.416Z | TRACE | Attempting to load session info from config file
2016-12-20T09:36:56.418Z | TRACE | check if session is invalidated
2016-12-20T09:36:57.077Z | TRACE | registry result 200 application/json undefined undefined false undefined
2016-12-20T09:36:57.078Z | TRACE | registry returned { expiry: 1482831415635 }
2016-12-20T09:36:57.078Z | TRACE | refresh session expiry to: 1482831415635
2016-12-20T09:36:57.080Z | TRACE | session expiry 1482831415635 false
2016-12-20T09:36:57.080Z | TRACE | session already loaded in opts.session
2016-12-20T09:36:57.105Z | DEBUG | Titanium Downloads Last Checked: 1482225107758
2016-12-20T09:36:57.128Z | TRACE | No project alloy hook; skipping update to 1.0.0
2016-12-20 10:37:00
Operating System
Name = Microsoft Windows 10 Pro
Version = 10.0.14393
Architecture = 32bit
# CPUs = 8
Memory = 34270777344
Node.js
Node.js Version = 4.5.0
npm Version = 2.15.9
Titanium CLI
CLI Version = 5.0.11
Titanium SDK
SDK Version = 6.0.0.GA
SDK Path = C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA
Target Platform = android
Command
C:\Program Files (x86)\nodejs\node.exe C:\Users\kronholm\.appcelerator\install\6.1.0\package\node_modules\titanium\lib\titanium.js build run --platform android --sdk 6.0.0.GA --log-level trace --project-dir C:\Dropbox\apps\testapp --deploy-type production --target dist-playstore --android-sdk C:\android --output-dir C:\Dropbox\apps\testapp --api-level 13 --alias tidev --keystore C:\Dropbox\apps\testapp\dev_keystore --store-password tirocks --key-password tirocks --no-colors --no-progress-bars --no-prompt --no-banner --prompt-type socket-bundle --prompt-port 60573 --username dan@bitfabrikken.dk --password khpcvnwr --config-file C:\Users\kronholm\AppData\Local\Temp\build-1482226617081.json --no-banner --project-dir C:\Dropbox\apps\testapp
[INFO] : Deploy type: production
[INFO] : Building for target: dist-playstore
[INFO] : Targeting Android SDK API: 23
[INFO] : Building for the following architectures: armeabi-v7a, x86
[INFO] : Signing with keystore: C:\Dropbox\apps\testapp\dev_keystore (tidev)
[INFO] : Debugging disabled
[INFO] : Profiler disabled
[INFO] : Forcing rebuild: JavaScript files need to be re-encrypted
[INFO] : JavaScript files need to be encrypted
[INFO] : Processing JavaScript files
[INFO] : Encrypting JavaScript files: C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\titanium_prep.win32.exe "dk.bitfabrikken.testapp" "C:\Dropbox\apps\testapp\build\android\assets" "app.js" "_app_props_.json"
[INFO] : Writing C:\Dropbox\apps\testapp\build\android\bin\assets\app.json
[INFO] : Extracting module resources: C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\modules\titanium-analytics.res.zip
[INFO] : Extracting module resources: C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\modules\titanium-android.res.zip
[INFO] : Extracting module resources: C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\modules\titanium-filesystem.res.zip
[INFO] : Extracting module resources: C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\modules\titanium-app.res.zip
[INFO] : Extracting module resources: C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\modules\titanium-media.res.zip
[INFO] : Extracting module resources: C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\modules\titanium-locale.res.zip
[INFO] : Extracting module resources: C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\modules\titanium-network.res.zip
[INFO] : Extracting module resources: C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\modules\titanium-xml.res.zip
[INFO] : No aidl files to compile, continuing
[INFO] : Generating i18n files
[INFO] : Generating C:\Dropbox\apps\testapp\build\android\res\values\theme.xml
[INFO] : Packaging application: C:\android\build-tools\23.0.3\aapt.exe "package" "-f" "-m" "-J" "C:\Dropbox\apps\testapp\build\android\gen" "-M" "C:\Dropbox\apps\testapp\build\android\AndroidManifest.xml" "-A" "C:\Dropbox\apps\testapp\build\android\bin\assets" "-S" "C:\Dropbox\apps\testapp\build\android\res" "-I" "C:\android\platforms\android-23\android.jar" "-F" "C:\Dropbox\apps\testapp\build\android\bin\app.ap_" "--auto-add-overlay" "--extra-packages" "ti.modules.titanium.ui:android.support.v7.appcompat:android.support.v7.cardview" "-S" "C:\Users\kronholm\AppData\Local\Temp\1161120-5884-1wr5l8w/res" "-S" "C:\Users\kronholm\AppData\Local\Temp\1161120-5884-62j53h/res" "-S" "C:\Users\kronholm\AppData\Local\Temp\1161120-5884-1t1lh48/res"
[INFO] : Building Java source files: c:\Program Files (x86)\Java\jdk1.8.0_111\bin\javac.exe "-J-Xmx1024M" "-encoding" "utf8" "-bootclasspath" "C:\android\platforms\android-23\android.jar;C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\kroll-v8.jar;C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\modules\titanium-analytics.jar;C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\aps-analytics.jar;C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\modules\titanium-android.jar;C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\jaxen-1.1.1.jar;C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\ti-commons-codec-1.3.jar;C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\kroll-common.jar;C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\titanium.jar;C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\android-support-multidex.jar;C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\modules\titanium-filesystem.jar;C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\modules\titanium-app.jar;C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\modules\titanium-ui.jar;C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\nineoldandroids-appc-2.4.0.jar;C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\modules\titanium-media.jar;C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\modules\titanium-appcompat.jar;C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\android-support-v4.jar;C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\android-support-v7-appcompat.jar;C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\modules\titanium-cardview.jar;C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\cardview-v7-23.0.1.jar;C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\modules\titanium-locale.jar;C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\modules\titanium-network.jar;C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\modules\titanium-xml.jar;C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\lib\titanium-verify.jar;R.class;AssetCryptImpl.class;TestappActivity.class;TestappAppInfo.class;TestappApplication.class" "-d" "C:\Dropbox\apps\testapp\build\android\bin\classes" "-proc:none" "-target" "1.6" "-source" "1.6" "@C:\Dropbox\apps\testapp\build\android\java-sources.txt"
[INFO] : Running dexer: c:\Program Files (x86)\Java\jdk1.8.0_111\bin\java.exe "-Xmx1024M" "-XX:-UseGCOverheadLimit" "-Djava.ext.dirs=C:\android\platform-tools" "-jar" "C:\android\build-tools\23.0.3\lib\dx.jar" "--dex" "--multi-dex" "--output=C:\Dropbox\apps\testapp\build\android\bin\dexfiles" "C:\Dropbox\apps\testapp\build\android\bin\classes" "C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\lib\titanium-verify.jar" "C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\kroll-v8.jar" "C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\modules\titanium-analytics.jar" "C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\aps-analytics.jar" "C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\modules\titanium-android.jar" "C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\jaxen-1.1.1.jar" "C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\ti-commons-codec-1.3.jar" "C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\kroll-common.jar" "C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\titanium.jar" "C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\android-support-multidex.jar" "C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\modules\titanium-filesystem.jar" "C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\modules\titanium-app.jar" "C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\modules\titanium-ui.jar" "C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\nineoldandroids-appc-2.4.0.jar" "C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\modules\titanium-media.jar" "C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\modules\titanium-appcompat.jar" "C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\android-support-v4.jar" "C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\android-support-v7-appcompat.jar" "C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\modules\titanium-cardview.jar" "C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\cardview-v7-23.0.1.jar" "C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\modules\titanium-locale.jar" "C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\modules\titanium-network.jar" "C:\ProgramData\Titanium\mobilesdk\win32\6.0.0.GA\android\modules\titanium-xml.jar"
[INFO] : Creating unsigned apk
[INFO] : Processing C:\Dropbox\apps\testapp\build\android\bin\dexfiles
[INFO] : Processing C:\Dropbox\apps\testapp\build\android\src
[INFO] : Writing unsigned apk: C:\Dropbox\apps\testapp\build\android\bin\app-unsigned.apk
[INFO] : Using MD5withRSA signature algorithm
[INFO] : Signing apk: c:\Program Files (x86)\Java\jdk1.8.0_111\bin\jarsigner.exe "-sigalg" "MD5withRSA" "-digestalg" "SHA1" "-keystore" "C:\Dropbox\apps\testapp\dev_keystore" "-storepass" "*******" "-keypass" "tirocks" "-signedjar" "C:\Dropbox\apps\testapp\build\android\bin\testapp.apk" "C:\Dropbox\apps\testapp\build\android\bin\app-unsigned.apk" "tidev"
[INFO] : Aligning zip file: C:\android\build-tools\23.0.3\zipalign.exe "-v" "4" "C:\Dropbox\apps\testapp\build\android\bin\testapp.apk" "C:\Dropbox\apps\testapp\build\android\bin\testapp.apkz"
[INFO] : Writing build manifest: C:\Dropbox\apps\testapp\build\android\build-manifest.json
[INFO] : Packaging complete
[INFO] : Package location: C:\Dropbox\apps\testapp\testapp.apk
[INFO] : Project built successfully in 18s 889ms
Logcat error when httpclient.error is not triggered - this usually happens before upload can get going
12-20 11:39:41.244: E/dalvikvm-heap(4508): Out of memory on a 52428816-byte allocation.
12-20 11:39:41.244: I/dalvikvm(4508): "main" prio=5 tid=1 RUNNABLE
12-20 11:39:41.244: I/dalvikvm(4508): | group="main" sCount=0 dsCount=0 obj=0x4187b578 self=0x417e61c0
12-20 11:39:41.244: I/dalvikvm(4508): | sysTid=4508 nice=0 sched=0/0 cgrp=apps handle=1075089404
12-20 11:39:41.244: I/dalvikvm(4508): | state=R schedstat=( 0 0 0 ) utm=450 stm=226 core=1
12-20 11:39:41.244: I/dalvikvm(4508): at java.io.ByteArrayOutputStream.toByteArray(ByteArrayOutputStream.java:~122)
12-20 11:39:41.252: I/dalvikvm(4508): at org.appcelerator.kroll.util.KrollStreamHelper.toByteArray(KrollStreamHelper.java:81)
12-20 11:39:41.252: I/dalvikvm(4508): at org.appcelerator.titanium.TiBlob.getBytes(TiBlob.java:327)
12-20 11:39:41.252: I/dalvikvm(4508): at ti.modules.titanium.network.TiHTTPClient.addTitaniumFileAsPostData(TiHTTPClient.java:866)
12-20 11:39:41.252: I/dalvikvm(4508): at ti.modules.titanium.network.TiHTTPClient.send(TiHTTPClient.java:1036)
12-20 11:39:41.260: I/dalvikvm(4508): at ti.modules.titanium.network.HTTPClientProxy.send(HTTPClientProxy.java:148)
12-20 11:39:41.260: I/dalvikvm(4508): at org.appcelerator.kroll.runtime.v8.V8Object.nativeFireEvent(Native Method)
12-20 11:39:41.260: I/dalvikvm(4508): at org.appcelerator.kroll.runtime.v8.V8Object.fireEvent(V8Object.java:62)
12-20 11:39:41.260: I/dalvikvm(4508): at org.appcelerator.kroll.KrollProxy.doFireEvent(KrollProxy.java:872)
12-20 11:39:41.260: I/dalvikvm(4508): at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1095)
12-20 11:39:41.260: I/dalvikvm(4508): at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:354)
12-20 11:39:41.260: I/dalvikvm(4508): at org.appcelerator.titanium.proxy.TiWindowProxy.handleMessage(TiWindowProxy.java:116)
12-20 11:39:41.260: I/dalvikvm(4508): at ti.modules.titanium.ui.WindowProxy.handleMessage(WindowProxy.java:453)
12-20 11:39:41.260: I/dalvikvm(4508): at android.os.Handler.dispatchMessage(Handler.java:95)
12-20 11:39:41.268: I/dalvikvm(4508): at android.os.Looper.loop(Looper.java:137)
12-20 11:39:41.268: I/dalvikvm(4508): at android.app.ActivityThread.main(ActivityThread.java:5103)
12-20 11:39:41.268: I/dalvikvm(4508): at java.lang.reflect.Method.invokeNative(Native Method)
12-20 11:39:41.268: I/dalvikvm(4508): at java.lang.reflect.Method.invoke(Method.java:525)
12-20 11:39:41.276: I/dalvikvm(4508): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
12-20 11:39:41.276: I/dalvikvm(4508): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
12-20 11:39:41.276: I/dalvikvm(4508): at dalvik.system.NativeStart.main(Native Method)
12-20 11:39:41.284: W/System.err(4508): java.lang.OutOfMemoryError
12-20 11:39:41.291: W/System.err(4508): at java.io.ByteArrayOutputStream.toByteArray(ByteArrayOutputStream.java:122)
12-20 11:39:41.291: W/System.err(4508): at org.appcelerator.kroll.util.KrollStreamHelper.toByteArray(KrollStreamHelper.java:81)
12-20 11:39:41.291: W/System.err(4508): at org.appcelerator.titanium.TiBlob.getBytes(TiBlob.java:327)
12-20 11:39:41.291: W/System.err(4508): at ti.modules.titanium.network.TiHTTPClient.addTitaniumFileAsPostData(TiHTTPClient.java:866)
12-20 11:39:41.291: W/System.err(4508): at ti.modules.titanium.network.TiHTTPClient.send(TiHTTPClient.java:1036)
12-20 11:39:41.291: W/System.err(4508): at ti.modules.titanium.network.HTTPClientProxy.send(HTTPClientProxy.java:148)
12-20 11:39:41.291: W/System.err(4508): at org.appcelerator.kroll.runtime.v8.V8Object.nativeFireEvent(Native Method)
12-20 11:39:41.291: W/System.err(4508): at org.appcelerator.kroll.runtime.v8.V8Object.fireEvent(V8Object.java:62)
12-20 11:39:41.291: W/System.err(4508): at org.appcelerator.kroll.KrollProxy.doFireEvent(KrollProxy.java:872)
12-20 11:39:41.291: W/System.err(4508): at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1095)
12-20 11:39:41.291: W/System.err(4508): at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:354)
12-20 11:39:41.291: W/System.err(4508): at org.appcelerator.titanium.proxy.TiWindowProxy.handleMessage(TiWindowProxy.java:116)
12-20 11:39:41.291: W/System.err(4508): at ti.modules.titanium.ui.WindowProxy.handleMessage(WindowProxy.java:453)
12-20 11:39:41.291: W/System.err(4508): at android.os.Handler.dispatchMessage(Handler.java:95)
12-20 11:39:41.291: W/System.err(4508): at android.os.Looper.loop(Looper.java:137)
12-20 11:39:41.291: W/System.err(4508): at android.app.ActivityThread.main(ActivityThread.java:5103)
12-20 11:39:41.291: W/System.err(4508): at java.lang.reflect.Method.invokeNative(Native Method)
12-20 11:39:41.291: W/System.err(4508): at java.lang.reflect.Method.invoke(Method.java:525)
12-20 11:39:41.299: W/System.err(4508): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
12-20 11:39:41.299: W/System.err(4508): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
12-20 11:39:41.299: W/System.err(4508): at dalvik.system.NativeStart.main(Native Method)
12-20 11:39:41.307: E/TiExceptionHandler(4508): (main) [2763,2763] ----- Titanium Javascript Runtime Error -----
12-20 11:39:41.307: E/TiExceptionHandler(4508): (main) [0,2763] - In ti:/httpclient.js:28,9
12-20 11:39:41.307: E/TiExceptionHandler(4508): (main) [1,2764] - Message: Uncaught Java Exception occurred
12-20 11:39:41.307: E/TiExceptionHandler(4508): (main) [0,2764] - Source: _send.call(this, options);
12-20 11:39:41.307: E/V8Exception(4508): Exception occurred at ti:/httpclient.js:28: Uncaught Java Exception occurred
12-20 11:39:41.307: E/V8Exception(4508): Java Exception occurred
Very good test-case and logs, thanks you! Moving to engineering.
Thanks Hans, it took many hours to narrow it down and test, but in making a good case I hope to expedite the fixing :)
master: https://github.com/appcelerator/titanium_mobile/pull/8710
Tested using environment: NPM Version: 2.15.9 Node Version: 4.5.0 Mac OS: 10.12.1 XCode 8.2 Appc CLI: 6.1.0 Appc CLI NPM: 4.2.8 Titanium SDK version: 6.1.0.v20170112013001 Appcelerator Studio, build: 4.8.1.201612050850 Android Device (New): 6.0.1 Android Device (Old): 4.4.2 I tested with both an old Android device 4.4.2, and with the new device 6.0.1. In both cases, the app appeared to work as expected. OutOfMemory errors weren't seen. When the app launched, a test 50MB file was uploaded, and an alert window popped up after a request was made to the website that is shown in the demo code. Although the usage of the app did not appear impacted, a repeating error was seen in the console for the older Android version only (4.4.2) It was not seen for 6.0.1: [~hansknoechel] I'm not sure if this error is related to this ticket, but in the console window, this error was seen repeating itself from the time the app was launched and continued on throughout the usage of the app.
The error you see is related to an internal Bluetooth LE (BLE) method called in the background (pretty sure it's Android itself). So probably the 4.4.1 device had Bluetooth on and was searching for results. Maybe there is a Bluetooth / Beacon related app on that testing device? But it's surely not related to this PR - [~gmathews] to confirm.
No, it doesn't seem related to this PR. I tried two other 4.4.2 phones, and those messages were not seen. I believe it is something wrong with that particular phone.