[AC-6460] Android is crashing when trying to delete a file in applicationDataDir
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Closed |
Resolution | Duplicate |
Resolution Date | 2020-02-05T22:33:16.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Titanium SDK & CLI |
Labels | android-10, android-8, android-9 |
Reporter | Caio Perdona |
Assignee | Nazmus Salahin |
Created | 2019-12-20T19:30:56.000+0000 |
Updated | 2020-09-11T18:38:46.000+0000 |
Description
When trying to delete a file inside applicationDataDir, android crashes with the following log:
[ERROR] TiExceptionHandler: (main) [1030,328883] ti:/invoker.js:105
[ERROR] TiExceptionHandler: return delegate.apply(invoker.__thisObj__, args);
[ERROR] TiExceptionHandler: ^
[ERROR] TiExceptionHandler: Error: Attempt to invoke virtual method 'java.lang.String java.lang.String.toLowerCase()' on a null object reference
[ERROR] TiExceptionHandler: at SandboxAPI.invoker [as getFile] (ti:/invoker.js:105:19)
[ERROR] TiExceptionHandler: at Object.exports.getf (/api.js:136:21)
[ERROR] TiExceptionHandler: at deleteFiles (/form/form4.js:2240:5)
[ERROR] TiExceptionHandler: at Titanium.checkStatus (/form/form4.js:2191:1)
[ERROR] TiExceptionHandler:
[ERROR] TiExceptionHandler: org.appcelerator.titanium.io.TiFileFactory.createTitaniumFile(TiFileFactory.java:88)
[ERROR] TiExceptionHandler: org.appcelerator.titanium.TiFileProxy.<init>(TiFileProxy.java:83)
[ERROR] TiExceptionHandler: ti.modules.titanium.filesystem.FileProxy.<init>(FileProxy.java:18)
[ERROR] TiExceptionHandler: ti.modules.titanium.filesystem.FilesystemModule.getFile(FilesystemModule.java:92)
[ERROR] TiExceptionHandler: org.appcelerator.kroll.runtime.v8.V8Function.nativeInvoke(Native Method)
[ERROR] TiExceptionHandler: org.appcelerator.kroll.runtime.v8.V8Function.callSync(V8Function.java:55)
[ERROR] TiExceptionHandler: org.appcelerator.kroll.runtime.v8.V8Function.call(V8Function.java:41)
[ERROR] TiExceptionHandler: ti.modules.titanium.TitaniumModule$Timer.run(TitaniumModule.java:167)
[ERROR] TiExceptionHandler: android.os.Handler.handleCallback(Handler.java:873)
[ERROR] TiExceptionHandler: android.os.Handler.dispatchMessage(Handler.java:99)
[ERROR] V8Exception: Exception occurred at ti:/invoker.js:105: Uncaught Error: Attempt to invoke virtual method 'java.lang.String java.lang.String.toLowerCase()' on a null object reference
The code that's triggering is:
var photoCacheDir = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, "myapp");
if (!photoCacheDir.exists()) { photoCacheDir.createDirectory(); }
Ti.Filesystem.getFile(photoCacheDir.resolve(), fname).deleteFile();
Hello! Thanks for reaching to us. What is your Ti SDK version? Could you share the steps to reproduce the issue in our end? Also, please share the complete trace. Thanks
@Nazmus Ti-SDK 8.3.0.GA I've already provided the steps to reproduce. var photoCacheDir = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, "myapp"); if (!photoCacheDir.exists()) { photoCacheDir.createDirectory(); } Ti.Filesystem.getFile(photoCacheDir.resolve(), fname).deleteFile(); When Ti tries to delete the file, the app crashes with the log given above.
[~perdona] I could not reproduce this issue. Please try with this sample code
If the issue persists then share a runnable test case. Thanks!
@Motiur, it is still happening here. Followed the same steps as you've done above. Turns out that the bug happens on the line with "Ti.Filesystem.getFile(dir.resolve(), f)" When I downgrade SDK to 8.2.1.GA the bug DOES NOT HAPPEN. How do we proceed?
[~perdona] Can you please share a reproducible test case? I could not reproduce the crash?
Happens to us as well on Android with 8.3.0.GA. Downgrading to 8.2.1.GA helped luckily. Unfortunately I am currenty unable to provide another test case. Would appreciate a fix though. Perhaps related to file system access permissions?
Same here @AppDev.
@Motiur, now I really don't have the time to share a runnable app, and this is kind of ineffective, bearing in mind that my app might have other properties and implementations that are different than the sample I would share, thus not reproducing the crash.
This is addressed by https://github.com/appcelerator/titanium_mobile/pull/11395
@Gary, is this expected to drop on 8.3.2.GA ?
[~ygbr] Looks like it's only scheduled for 9.0.0.GA
Isn't this critical enough for backporting the fix to 8.X.X?
PS: it seems simple enough for backporting the fix by applying https://github.com/appcelerator/titanium_mobile/pull/11395/files to https://github.com/appcelerator/titanium_mobile/blob/e9ef3702af3f75327af9056ec0bb9a7bf209e130/android/titanium/src/java/org/appcelerator/titanium/io/TitaniumBlob.java#L89 This has become a blocker on our main production app since we can't delete files anymore on android, filling users storage unnecessarily.
[~ygbr]: here is the 8.3.1 branch with the TitaniumBlob changes merged in: https://migaweb.de/mobilesdk-8.3.1-linux.zip
@miga Can you provide the OSX version, please?
since it is only an Android change you can just rename the linux part to osx or use the iOS version from here: http://builds.appcelerator.com/#8_3_X and replace the Android folder with the one from my zip
Hi Michael, We are facing the same issue in production with 8.3.1GA SDK. Unfortunately we can't move to 9.0 GA SDK currently. We tried to use above 8.3.1 branch with bob changes but could not access the link https://migaweb.de/mobilesdk-8.3.1-linux.zip Could you please help us on this.
[~Snigdha.Nooli] I've rebuild the SDK and the link is working again. Normally you can just clone the repo, include the PR and build it yourself
Thanks for the help Michael.