Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-26716] Android: 'Error while reading asset' Can be seen intermittently when running certain Android applications

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2019-01-18T19:30:46.000+0000
Affected Version/sRelease 8.0.0
Fix Version/sRelease 8.0.0
ComponentsAndroid
Labelsn/a
ReporterSamir Mohammed
AssigneeJan Vennemann
Created2019-01-11T17:14:58.000+0000
Updated2019-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.
[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();

Run the program using the latest SDK from 8_0_x

Theirs a chance the above error will be shown in the console

*Actual result* Sometimes the application logs the above error but application still works as expected. *Expected result* Application should run without any issues and console should not log any errors.

Comments

  1. Christopher Williams 2019-01-15

    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).
  2. Christopher Williams 2019-01-15

    [~jvennemann] just noted in our standup that this seems to work fine on first clean build, but subsequent builds exhibit this bug.
  3. Christopher Williams 2019-01-16

    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.
  4. Jan Vennemann 2019-01-16

    PR (master): https://github.com/appcelerator/titanium_mobile/pull/10622 PR (8_0_X): https://github.com/appcelerator/titanium_mobile/pull/10623
  5. Lokesh Choudhary 2019-01-17

    FR Passed. PR's merged.
  6. Keerthi Mahalingam 2019-01-18

    Verified the fix on SDK 8.1.0.v20190117115327 and 8.0.0.v20190117115226.No error displayed.works fine. Closing
        Name                        = Mac OS X
         Version                     = 10.13.6
         Memory                      = 17179869184
       Node.js
         Node.js Version             = 8.12.0
         npm Version                 = 6.4.1
       Titanium CLI
         CLI Version                 = 5.1.1
       Titanium SDK
         SDK Version                 = 8.1.0.v20190117115327 and 8.0.0.v20190117115226
       App CLI                          =7.0.10.master 5
       Device                           =Samsung s5 android 6
       Emulator                       =Pixel 3 xl android 9
       

JSON Source