[TIMOB-26716] Android: 'Error while reading asset' Can be seen intermittently when running certain Android applications
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2019-01-18T19:30:46.000+0000 |
Affected Version/s | Release 8.0.0 |
Fix Version/s | Release 8.0.0 |
Components | Android |
Labels | n/a |
Reporter | Samir Mohammed |
Assignee | Jan Vennemann |
Created | 2019-01-11T17:14:58.000+0000 |
Updated | 2019-01-18T19:30:46.000+0000 |
Description
The following error can be seen intermittently when running certain Android applications on the latest SDK in 8_0_x. The application seems to work without any issues but the error is logged in the console.
Build the module for android (CD in to the android directory of the module and run
Add the following in to the
[ERROR] : TiAssetHelper: Error while reading asset "Resources/node_modules/core-js/modules/web.dom.iterable.js":
[ERROR] : TiAssetHelper: java.io.FileNotFoundException: Resources/node_modules/core-js/modules/web.dom.iterable.js
[ERROR] : TiAssetHelper: at android.content.res.AssetManager.nativeOpenAsset(Native Method)
[ERROR] : TiAssetHelper: at android.content.res.AssetManager.open(AssetManager.java:744)
[ERROR] : TiAssetHelper: at android.content.res.AssetManager.open(AssetManager.java:721)
[ERROR] : TiAssetHelper: at org.appcelerator.kroll.util.KrollAssetHelper.readAsset(KrollAssetHelper.java:165)
[ERROR] : TiAssetHelper: at org.appcelerator.kroll.runtime.v8.V8Runtime.nativeRunModule(Native Method)
[ERROR] : TiAssetHelper: at org.appcelerator.kroll.runtime.v8.V8Runtime.doRunModule(V8Runtime.java:162)
[ERROR] : TiAssetHelper: at org.appcelerator.kroll.KrollRuntime.runModule(KrollRuntime.java:207)
[ERROR] : TiAssetHelper: at org.appcelerator.titanium.TiLaunchActivity.loadScript(TiLaunchActivity.java:97)
[ERROR] : TiAssetHelper: at org.appcelerator.titanium.TiRootActivity.loadScript(TiRootActivity.java:414)
[ERROR] : TiAssetHelper: at org.appcelerator.titanium.TiLaunchActivity.windowCreated(TiLaunchActivity.java:174)
[ERROR] : TiAssetHelper: at org.appcelerator.titanium.TiRootActivity.windowCreated(TiRootActivity.java:283)
[ERROR] : TiAssetHelper: at org.appcelerator.titanium.TiBaseActivity.onCreate(TiBaseActivity.java:767)
[ERROR] : TiAssetHelper: at org.appcelerator.titanium.TiLaunchActivity.onCreate(TiLaunchActivity.java:167)
[ERROR] : TiAssetHelper: at org.appcelerator.titanium.TiRootActivity.onCreate(TiRootActivity.java:260)
[ERROR] : TiAssetHelper: at android.app.Activity.performCreate(Activity.java:7136)
[ERROR] : TiAssetHelper: at android.app.Activity.performCreate(Activity.java:7127)
[ERROR] : TiAssetHelper: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
[ERROR] : TiAssetHelper: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
[ERROR] : TiAssetHelper: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
[ERROR] : TiAssetHelper: at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
[ERROR] : TiAssetHelper: at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
[ERROR] : TiAssetHelper: at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
[ERROR] : TiAssetHelper: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
[ERROR] : TiAssetHelper: at android.os.Handler.dispatchMessage(Handler.java:106)
[ERROR] : TiAssetHelper: at android.os.Looper.loop(Looper.java:193)
[ERROR] : TiAssetHelper: at android.app.ActivityThread.main(ActivityThread.java:6669)
[ERROR] : TiAssetHelper: at java.lang.reflect.Method.invoke(Native Method)
[ERROR] : TiAssetHelper: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
[ERROR] : TiAssetHelper: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
*A test scenario:* *Note* The error can also be shown using the kitchenSink-V2 application
Clone the repo https://github.com/appcelerator-modules/titanium-web-dialog
Build the module for android (CD in to the android directory of the module and run appc run --build-only
)
Add the module into the Titanium modules directory
Create a new Titanium application
Add the following in to the app.js
var WebDialog = require('ti.webdialog');
var win = Ti.UI.createWindow({
backgroundColor: '#fff'
});
var btnOpenDialog = Ti.UI.createButton({
title: 'Open Web Dialog'
});
win.add(btnOpenDialog);
btnOpenDialog.addEventListener('click', function () {
WebDialog.open({
url: 'https://appcelerator.com',
title: 'Hello World',
// iOS 10+
tintColor: 'red',
barColor: 'green',
// iOS 11+
barCollapsingEnabled: false,
dismissButtonStyle: WebDialog.DISMISS_BUTTON_STYLE_CLOSE
});
});
WebDialog.addEventListener('open', function (event) {
console.log('open: ' + JSON.stringify(event));
});
WebDialog.addEventListener('close', function (event) {
console.log('close: ' + JSON.stringify(event));
});
win.open();
I'd treat this as a blocker, as the app will fail to load altogether when this does happen. There's a couple PRs that could possibly "fix" this: - https://github.com/appcelerator/titanium_mobile/pull/10613 - This updates our fs-extra dependency to the latest release. Maybe that'll fix the issue it has in not always copying everything over during app builds? - https://github.com/appcelerator/titanium_mobile/pull/10567 - This is where we'd "pre-ship" the polyfills when we built the SDK. I didn't intend to ship this in 8.0.0 originally, but it could "fix" the issue by doing the copy of the polyfills in our SDK build and we can then do some sort of enforced sanity check that the expected files exist or fail our own build. The "con" here is that there's potentially an app startup performance hit since the polyfills would be loaded during startup (rather than as they're used within the app).
[~jvennemann] just noted in our standup that this seems to work fine on first clean build, but subsequent builds exhibit this bug.
Assigning to Jan since he can fairly reliably reproduce on Android simulator. I'll also be trying to reproduce/fix, but hopefully Jan can nail this one.
PR (master): https://github.com/appcelerator/titanium_mobile/pull/10622 PR (8_0_X): https://github.com/appcelerator/titanium_mobile/pull/10623
FR Passed. PR's merged.
Verified the fix on SDK 8.1.0.v20190117115327 and 8.0.0.v20190117115226.No error displayed.works fine. Closing