[TIMOB-15821] Android: Unable to access files in Resources folder
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2013-11-26T22:47:32.000+0000 |
Affected Version/s | Release 3.2.0 |
Fix Version/s | 2013 Sprint 24, 2013 Sprint 24 Core, Release 3.2.0 |
Components | Android |
Labels | SupportTeam, module_android, qe-testadded, regression, triage |
Reporter | Dan Tamas |
Assignee | Chris Barber |
Created | 2013-11-25T15:14:22.000+0000 |
Updated | 2014-05-30T20:46:43.000+0000 |
Description
It seems that for some reason the files in the Resources folder are not found anymore.
The testcase is for a sound file, but the same happens if I try to simply get a file with
(Titanium.Filesystem.getFile(Titanium.Filesystem.resourcesDirectory ,'core/data_providers/phone_db.js').read().text
*Testcase* app.js
var win = Ti.UI.createWindow({
backgroundColor:'#f00'
});
win.open();
var newMsgSound = Titanium.Media.createSound({
url: '/samsung_sherbet.mp3',
preload: true
});
newMsgSound.play();
result:
11-25 16:09:33.319: E/TiSound(17910): (KrollRuntimeThread) [524,525] Error setting file descriptor:
11-25 16:09:33.319: E/TiSound(17910): java.io.FileNotFoundException: This file can not be opened as a file descriptor; it is probably compressed
11-25 16:09:33.319: E/TiSound(17910): at android.content.res.AssetManager.openAssetFd(Native Method)
11-25 16:09:33.319: E/TiSound(17910): at android.content.res.AssetManager.openFd(AssetManager.java:379)
11-25 16:09:33.319: E/TiSound(17910): at ti.modules.titanium.media.TiSound.initializeAndPlay(TiSound.java:100)
11-25 16:09:33.319: E/TiSound(17910): at ti.modules.titanium.media.TiSound.play(TiSound.java:212)
11-25 16:09:33.319: E/TiSound(17910): at ti.modules.titanium.media.SoundProxy.play(SoundProxy.java:151)
11-25 16:09:33.319: E/TiSound(17910): at org.appcelerator.kroll.runtime.v8.V8Runtime.nativeRunModule(Native Method)
11-25 16:09:33.319: E/TiSound(17910): at org.appcelerator.kroll.runtime.v8.V8Runtime.doRunModule(V8Runtime.java:159)
11-25 16:09:33.319: E/TiSound(17910): at org.appcelerator.kroll.KrollRuntime.handleMessage(KrollRuntime.java:289)
11-25 16:09:33.319: E/TiSound(17910): at org.appcelerator.kroll.runtime.v8.V8Runtime.handleMessage(V8Runtime.java:185)
11-25 16:09:33.319: E/TiSound(17910): at android.os.Handler.dispatchMessage(Handler.java:95)
11-25 16:09:33.319: E/TiSound(17910): at android.os.Looper.loop(Looper.java:156)
11-25 16:09:33.319: E/TiSound(17910): at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:112)
11-25 16:09:33.319: I/MediaPlayer(17910): setLPAflag() in
11-25 16:09:33.319: I/MediaPlayer(17910): mContext is null, can't getMirrorDisplayStatus!!!
11-25 16:09:33.319: I/MediaPlayer(17910): setLPAflag() out
11-25 16:09:33.319: E/MediaPlayer(17910): prepareAsync called in state 1
11-25 16:09:33.329: W/TiSound(17910): (KrollRuntimeThread) [7,532] Issue while initializing :
11-25 16:09:33.329: W/TiSound(17910): java.lang.IllegalStateException
11-25 16:09:33.329: W/TiSound(17910): at android.media.MediaPlayer._prepare(Native Method)
11-25 16:09:33.329: W/TiSound(17910): at android.media.MediaPlayer.prepare(MediaPlayer.java:1341)
11-25 16:09:33.329: W/TiSound(17910): at ti.modules.titanium.media.TiSound.initializeAndPlay(TiSound.java:153)
11-25 16:09:33.329: W/TiSound(17910): at ti.modules.titanium.media.TiSound.play(TiSound.java:212)
11-25 16:09:33.329: W/TiSound(17910): at ti.modules.titanium.media.SoundProxy.play(SoundProxy.java:151)
11-25 16:09:33.329: W/TiSound(17910): at org.appcelerator.kroll.runtime.v8.V8Runtime.nativeRunModule(Native Method)
11-25 16:09:33.329: W/TiSound(17910): at org.appcelerator.kroll.runtime.v8.V8Runtime.doRunModule(V8Runtime.java:159)
11-25 16:09:33.329: W/TiSound(17910): at org.appcelerator.kroll.KrollRuntime.handleMessage(KrollRuntime.java:289)
11-25 16:09:33.329: W/TiSound(17910): at org.appcelerator.kroll.runtime.v8.V8Runtime.handleMessage(V8Runtime.java:185)
11-25 16:09:33.329: W/TiSound(17910): at android.os.Handler.dispatchMessage(Handler.java:95)
11-25 16:09:33.329: W/TiSound(17910): at android.os.Looper.loop(Looper.java:156)
11-25 16:09:33.329: W/TiSound(17910): at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:112)
Regression? Testcase works fine in 3.1.3GA.
Could we prioritise this a little? It's a showstopper for us. Thank you.
Fix version 3.3.0?
And merge-3.2.0 label. We're now in backport season.
Surely this is a blocker?
@Ingo, what does this means? That you are working in 3.3.0 but until 3.2.0 will be released, the fix will be also back ported to 3.2.0 ? Thnx
We have branched for 3.2.X, so we will be making the fix for 3.2.0 _and_ 3.3.0
@Ingo That made me happy! :)
Since there is some confusion about our process, I'll detail it here:
Tickets are always resolved in the master branch first. As of yesterday, we created a 3.2.X branch in git, and master became 3.3.0
However, it is important this goes into 3.2.0. Thus, we add a merge-3.2.0 label.
Once we've resolved the ticket in master, it's marked "Resolved".
We then set up a backport PR against the 3.2.X branch.
Once the ticket is resolved in 3.2.X, we remove the merge-3.2.0 label and add the fix version of 3.2.0
This process is done to make sure the dev and QE teams know where the fix sits and can be properly tested. For developers, the key thing is to look at the fix version fields, or the labels. You'll now see a bunch of merge-3.2.0 tags (meaning it will go into 3.2.0), or merge-3.2.1 tags (meaning it will go into 3.2.1).Thank you :)
Master pull request: https://github.com/appcelerator/titanium_mobile/pull/5033 3_2_X pull request: https://github.com/appcelerator/titanium_mobile/pull/5034
To test: Run the sound and movie tests in KS. Phone > Play Movie > Local Phone > Sound > Local
Verified the fix & we can access the local resources in side the app. Tested it using KS, Phone > Play Movie > Local & Phone > Sound > Local Works as expected. Closing. Environment: Appcel Studio : 3.2.0.201311252112 Ti SDK : 3.2.0.v20131126144841 Mac OSX : 10.8.5 Alloy : 1.3.0-alpha6 CLI - 3.2.0-alpha3 Nexus 4 - android 4.2
@Chris I get this error with the build Lokesh tested
The only thing that comes to my mind is that I have A LOT of files in the app. Any thought? Thank you.
[~rborn], thanks! 1. How many files do you have exactly? Can you give a count from the terminal? 2. Can you try upping the stack size by passing it in as part of the command to see if that helps? For example, in the code-analyzer, we used the following command: "node --stack-size=10000 /usr/local/bin/titanium analyze -p
Files:
Trying to increase the stack size, none of the below work
:( Am I doing it wrong ?
analyze gives me this:
Likely right, but that fix may not work here. I'm reviewing other instances of that error: TIMOB-13388, and it may involve a different change. I'll let [~cbarber] weigh in. Analyze likely won't work unless you install the 3.2.0-era version of the code analyzer, which we've not publicized yet.
Ok, thanks
So, after Stephen asked why excluding some file formats instead of only compressing the js ones, I did this
in https://github.com/appcelerator/titanium_mobile/blob/master/android/cli/commands/_build.js#L3566 The error is gone and the sound gets on the device with this command
however the normal build still complains about the stack size. [cbarber] As Stephen was asking, why do we eliminate some files instead of compressing only the ones we need? If I add some files with a weird extension, this will break. Also the fix has another issue (the sound works ok now, except the stack error) I have to eval a js file - don't ask why, external module for gcm that needs to take some info from the app Well, this breaks too, and because of this I cannot show the notification.
ddms error:
there is more but basically it's the same "file not found" error This was working too in 3.1.3 Sorry to be such a a pita :)
[~rborn] No, this is helpful! FWIW, we did rewrite the ENTIRE Android build infrastructure, so it's to be expected something doesn't quite work as before, and we can't write enough test cases to cover every possible usage.
...like 100000000000000 files in the project :D
http://support.apple.com/kb/ht2422. 2.1 B is the max. 2100000000. We can't support 100 trillion :) (100,000,000,000,000)
haha :D
[~rborn] When we call aapt, it generates app.ap_. We then open this file as a zip and combine its contents with the contents of all jar file dependencies. The result is the unsigned apk file. Turns out that certain resources (images, videos, audio, etc) must NOT be compressed inside the apk file. Before yesterday, every file in the unsigned apk was compressed. Turns out that's bad. After investigating what the old Android builder.py does, it turns out they only compresses certain file types. The fix for this ticket is to exclude files from being compressed, thus matching the old behavior. Since we're now using a different code path inside the "archiver" node.js module when creating the unsigned apk, it appears a stack size bug has appeared. I'm investigating a fix. Stay tuned.
Thnx Chris.