[TIMOB-16093] Android: Failed to encrypt JavaScript files (OS X)
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Reopened |
Resolution | Unresolved |
Affected Version/s | n/a |
Fix Version/s | 2014 Sprint 01, 2014 Sprint 01 Core, Release 3.3.0 |
Components | Android |
Labels | cb-tooling |
Reporter | Keylo E. |
Assignee | Chris Barber |
Created | 2013-12-23T22:41:31.000+0000 |
Updated | 2016-08-19T04:28:52.000+0000 |
Description
Attachments
File | Date | Size |
---|---|---|
.log | 2013-12-23T22:41:32.000+0000 | 0 |
diagnostic8251845148288191520.log | 2013-12-23T22:41:35.000+0000 | 15329 |
problemfile.js | 2014-01-16T02:45:24.000+0000 | 141895 |
Thanks for reporting this issue. Engineering is actively looking into this. please watch TIMOB-16073 for more updates.
To confirm, this is for OS X + Android, yes? All other reports have been on Windows so far.
Note to developers: Host OS: Mac OS X OS Version: 10.9 OS Arch: x86 JRE Version: 1.6.0_65 JRE Vendor: Apple Inc. JRE Home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
[~keylo] Can you please try an experiment? Can you try building your project, but remove 50% of the ui/common/* files? We have an issue with the amount of data the encryption process will encrypt at once. This _should_ not have changed between 3.1.3 and 3.2.0, but just to eliminate the issue, I'd like to try this out. Another way to test is just to build a brand new Android project, and see if it fails there.
[~keylo] Would it be possible for you to attach a complete project that reproduces this issue? You can either attach it to this ticket or send me by direct email at ragrawal@appcelerator.com? We have been trying to reproduce this issue with no success so far.
Cannot. Client privacy forbids. Stab in the dark but could you take a look at the tiapp.xml since error contains "build-manifest.json does not exist" and adjusting it fixed for iOS. from
classic, not alloy
.. and
Keylo, could you clarify "adjusting it [build-manifest.json] fixed for iOS"? My current hunch is this is a duplicate of TIMOB-16077, but we really need some project to duplicate the issue. We know there is a problem with the amount of JavaScript, but we expected the limits to be identical to 3.1.3.
Referring to my original report. After update, iOS suggested removing the android:largeHeap ='true' from tiapp.xml, which worked for latest build, then moved on to Android and..
Keylo, We have been unable to reproduce this issue., and yours so far is the only report. Can you please provide some project that reproduces the issue for you?
Deferring to 3.2.2 until we get more information.
got around to stripping the project down. Found that the culprit was this export: The prob object had 1000 lines, each with a string, some fairly long. Works for iOS, not android. in ProblemFile.js.. function ProblemFile() { var prob = { "title 1" : "Name, Name, Name, Name, Name, Name, Name, Name, Name", ... "title 1000" : "Name, Name, Name, Name, Name, Name, Name, Name, Name, Name, Name, Name, Name" }; return data; } module.exports = ProblemFile;
I tried to reproduce this by replicating the ProblemFile.js, but it built successfully for Android device on Mac OS X 10.8.5 (Mountain Lion). I don't have Mavericks to test with at this moment. I doubled the amount of lines from 1000 to 2000 and it still worked. I then copied the file 10 times and it still worked. I copied the file 100 times and it still worked. I tried 200 copies, but titanium_prep ran out of memory and caused a completely different error. In any case, I'm resolving as cannot reproduce. I have attached my version of the ProblemFile.js for anyone who's bored.
I am having the same issue on OSX 10.9.1. Has there been any resolution? Let me know if you need the project.
Leonardo, yes, please attach your project.
Chris, we are having this exact same issue. Our build process combines all of our JS into a single app.js. This app.js ends up being 43k lines and 1.2MB of code - we do this because we've found the app is significantly quicker to launch if we can skip include calls. I noticed via browsing various github repos that the build process was recently rewritten for android. We are on Mavericks, trying to use TiSDK 3.2.0GA.
[~jbzdawka] To confirm, it used to work for you in 3.1.3 and no longer works in 3.2.0? Any way you can attach (or email us privately) your application code as a test file?
Correct, 3.1.3 is fine and 3.2.0 throws the encryption error. I am unable to share the code - even privately. We do have a custom manifest file - but I am not sure if that could cause this problem. I've also tried on multiple computers (all Mavericks) and the problem is present on all.
[~cbarber] here is a way to replicate the issue. (just having it now :( ) Go to http://www.json-generator.com/, set the repeat to something like 9999 (though 500 will do it)
generate, copy to clipboard and put in a single js file in Resources. Then try to compile with
Reopening because titanium_prep needs to be fixed to handle large JavaScript files.
What is the fix to come around this? THIS IS URGENT!! Made a big update for iOS and now I cannot continue for Android. No problem on iOS, big troubles on Android. This is again a discrepancy between the two major platforms Appcelerator derives its existance from.
[~ray@raymondverbruggen.nl] I assume it's breaking during the call to titanium_prep and resulting in the "Failed to encrypt JavaScript files" message, correct? What operating system are you on? Is it possible to try building your app on a different operating system? Does your app have a lot of JavaScript code? Do you know how many JS files? How big are they?
OSX Mavericks is my operating system, it is not possible to build for another OS. I have chosen Appcelerator because of the multi-platform, Android and iOS and so OSX. "app.js" "alloy/backbone.js" "alloy/constants.js" "alloy/controllers/BaseController.js" "alloy/controllers/facebook.js" "alloy/controllers/help.js" "alloy/controllers/home.js" "alloy/controllers/index.js" "alloy/controllers/mainview.js" "alloy/controllers/mapView.js" "alloy/controllers/menuview.js" "alloy/controllers/settings.js" "alloy/controllers/twitter.js" "alloy/models/Partners.js" "alloy/styles/facebook.js" "alloy/styles/help.js" "alloy/styles/home.js" "alloy/styles/index.js" "alloy/styles/mainview.js" "alloy/styles/mapView.js" "alloy/styles/menuview.js" "alloy/styles/settings.js" "alloy/styles/twitter.js" "alloy/sync/localStorage.js" "alloy/sync/properties.js" "alloy/sync/sql.js" "alloy/underscore.js" "alloy/widget.js" "alloy/widgets/com.imagitechdj.slideMenu/controllers/widget.js" "alloy/widgets/com.imagitechdj.slideMenu/styles/widget.js" "alloy.js" "lib/httpClient.js" "lib/shadow.js" "lib/utils.js" "openlayers/OpenLayers.js" "openlayers/mobile.js" "openlayers/proj4.js" "slideMenu/slideMenu.js" "_app_props_.json" The largest is Openlayers.js, 770kb
[~ray@raymondverbruggen.nl] OK, so you don't have that many files. Titanium_prep is sensitive to the total size of all JS files combined. Perhaps the files combined are large? Another thing you can try is right after it fails, locate the text in the output "Encrypting JavaScript files:" and copy everything afterwards and run titanium_prep manually. What does it output? Does it display any errors? What is the exit code? (echo $?)
I had the same issue and it was solved exporting this environment variable: export JAVA_TOOL_OPTIONS="-XX:+HeapDumpOnOutOfMemoryError -Xmx1024m -XX:MaxPermSize=256m" The main problem is related with use of memory
[~juanblo] Brilliant! Thanks for this tip. I'll test it and if it solves the problem, I'll add it to Android's build so that you don't have to worry about it.
Unfortunately, the export JAVA_TOOL_OPTIONS did not work for me. I get a file is too big error regardless of the max memory setting for java, etc. The command I run is: ~/Library/Application\ Support/Titanium/mobilesdk/osx/3.3.0.GA/android/titanium_prep.macos "com.movatohealth.phoenix" "/Users/Jeff/Desktop/Projects/TiWorkspace/Phoenix/build/android/assets" "app.js" The output is: Picked up JAVA_TOOL_OPTIONS: -XX:+HeapDumpOnOutOfMemoryError -Xmx2048m -Xms2048m -XX:MaxPermSize=1024m File is too big. You can see I was increasing the numbers as I fiddled with it to try to get it to work. That app.js is 839kb, we have a build process that creates a single app.js from ~400 javascript files via a plugin and pre compile hook. Through trial and error I think I stumbled on a max file size of 500kb for a single file for titanium_prep.macos for android. We're working on a build script that tries to stay under 500kb per file and splits it in an intelligent spot so that we stay under that cap that is currently a theory on our part - will report back on if staying under that theorized cap works for us.
Aiming for around 512kb in breaking down our files worked. This is purely anecdotal, but the sum of files can be far in excess of 512kb but for us an individual file could not be greater than 512kb otherwise we got a "file is too big" error.
[~jbzdawka] I don't have a magic workaround right this minute. titanium_prep takes a bunch of input .js files and encrypts them and that output is injected into the a .java file. I have managed to generate a 20MB .java file that fails to compile because 256MB of memory is not enough. I did make it so you can override the javac max memory (
ti config android.javac.maxmemory 1G
). But you are hung up on titanium_prep and unfortunately I don't know a way of boosting the number of files or size of files that are to be encrypted. If I was able to generate a 20MB .java file, I can guarantee you that I had way more than 512KB of .js files. When I tested it, I think I was testing using a TON of jquery.js files.Dear Appcelerator developers! Any news on this issue?? This is really a big problem!
After wrestling with this issue all week I was able to work around it by creating a link to the library as described here: http://stackoverflow.com/a/23696459/2272365 In Terminal.app:
You'll have to change the jdk1.x.x_xx.jdk directory to match whatever you have installed. Another option is to modify the Titanium SDK "_build.js" file and set encryptJS to false (around line 934). I wouldn't recommend that method for anything important though. This file should be located somewhere like "/Users/ben/Library/Application Support/Titanium/mobilesdk/osx/3.4.0.GA/android/cli/commands/_build.js"
Any progress on this one???? When is a solution provided?
Does anybody have a workaround for this? This one is putting my project on a hold!
thanks [~ben0] I've modified /Library/Application Support/Titanium/mobilesdk/osx/3.4.0.GA/android/cli/commands/_build.js (just the test environment) will deal with it when I go to production.
This bug is now exacerbated by El Capitan's lack of Java 6 support. The workaround from Ben fixed it for me, but it's still a problem in SDK 4.0.0.GA and 4.1.0.GA.
Is it possible to have selective encryption? For example in a project select which js file get encrypted or even just have a master file that gets encrypted ( alloy.js ) so that data in there is 'secure' - I use the term loosely. Even prefix or suffix files that need to be included in the encryption process enc_xxx.js or xxx_enc.js or xxxx.enjs