Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-25242] Android: V8Exception on launch

GitHub Issuen/a
TypeBug
PriorityNone
StatusClosed
ResolutionFixed
Resolution Date2017-11-15T22:27:12.000+0000
Affected Version/sn/a
Fix Version/sRelease 7.0.0
ComponentsAndroid
Labelsn/a
ReporterShuo Liang
AssigneeGary Mathews
Created2017-09-07T01:19:35.000+0000
Updated2017-11-16T00:10:41.000+0000

Description

Customer is facing to the following problem. Sometimes our app hangs when launched on android. It doesn't happen every time, but sometimes it will happen fairly frequently on a given device (as much as 30-40% of the time). It appears that this exception is to blame
09-01 14:29:06.650  5042  5042 E TiExceptionHandler: (main) [21,21] ----- Titanium Javascript Runtime Error -----
09-01 14:29:06.650  5042  5042 E TiExceptionHandler: (main) [0,21] - In ti:/module.js:622,21
09-01 14:29:06.650  5042  5042 E TiExceptionHandler: (main) [0,21] - Message: Uncaught TypeError: Cannot use 'in' operator to search for 'Resources/TitanUp/TitanUp' in null
09-01 14:29:06.650  5042  5042 E TiExceptionHandler: (main) [0,21] - Source:    return filename in fileIndex;
09-01 14:29:06.651  5042  5063 E V8Exception: Exception occurred at ti:/module.js:622: Uncaught TypeError: Cannot use 'in' operator to search for 'Resources/TitanUp/TitanUp' in null
09-01 14:29:06.675  2366  2377 D InputDispatcher: Focus entered window: 5042
(TitanUp is a commonjs module belong to customer) Attached is the full adb log for the process in question. And customer believe that is probably a bug inside the Titanium runtime. Customer also complain that "How could our Javascript trigger an exception like this so early in the application's life cycle? It looks like a problem *resolving* the path to our library, which suggests that it is inside the Titanium runtime." Please advise.

Attachments

FileDateSize
log-bad-proc.txt2017-09-07T01:18:40.000+00009035

Comments

  1. Gary Mathews 2017-09-12

    master: https://github.com/appcelerator/titanium_mobile/pull/9422
  2. Shuo Liang 2017-09-20

    Any update on this? I see there is PR. Will this fix the problem, Which version will be expected about this fix.
  3. Christopher Williams 2017-10-02

    [~gmathews] So the full log shows the real root cause. That failure to load the JS file via require is actually a symptom here, not the root cause of the issue. Look at lines 2 and 5 here:
       09-01 14:29:06.409  5042  5042 I TiRootActivity: (main) [0,0] checkpoint, on root activity create, savedInstanceState: null
       09-01 14:29:06.553  5042  5063 E TiAssetHelper: AssetManager is null, can't read asset: app.json
       09-01 14:29:06.577  5042  5063 W TiApplication: (KrollRuntimeThread) [168,168] Registering module with name already in use.
       09-01 14:29:06.607  5042  5063 I TiAPI   :  [app] startup; requiring minimal modules to get window open
       09-01 14:29:06.612  5042  5063 E TiAssetHelper: AssetManager is null, can't read asset: index.json
       09-01 14:29:06.626  5042  5042 D SensorManager: registerListener :: 1, LSM6DS3 Accelerometer, 200000, 0,  
       09-01 14:29:06.629  5042  5042 I TiRootActivity: (main) [0,0] checkpoint, on root activity resume. activity = com.mylocaltv.wral.WralNewsActivity@ed5c8a3
       09-01 14:29:06.649  5042  5042 D InputTransport: Input channel constructed: fd=106
       09-01 14:29:06.649  5042  5042 D ViewRootImpl@dedd4cf[WralNewsActivity]: setView = DecorView@c34de5c[WralNewsActivity] touchMode=true
       09-01 14:29:06.650  5042  5042 E TiExceptionHandler: (main) [21,21] ----- Titanium Javascript Runtime Error -----
       09-01 14:29:06.650  5042  5042 E TiExceptionHandler: (main) [0,21] - In ti:/module.js:622,21
       09-01 14:29:06.650  5042  5042 E TiExceptionHandler: (main) [0,21] - Message: Uncaught TypeError: Cannot use 'in' operator to search for 'Resources/TitanUp/TitanUp' in null
       09-01 14:29:06.650  5042  5042 E TiExceptionHandler: (main) [0,21] - Source: 	return filename in fileIndex;
       09-01 14:29:06.651  5042  5063 E V8Exception: Exception occurred at ti:/module.js:622: Uncaught TypeError: Cannot use 'in' operator to search for 'Resources/TitanUp/TitanUp' in null
       
    So the real issue here is that we're hitting this: https://github.com/appcelerator/titanium_mobile/blob/master/android/runtime/common/src/java/org/appcelerator/kroll/util/KrollAssetHelper.java#L57 It looks like KrollAssetHelper.init() is getting called too late, which is called via KrollRuntime.init(), which is called during the app's onCreate() lifecycle callback. My best guess here is that we should be moving that init call up higher in that method: https://github.com/appcelerator/titanium_mobile/blob/master/android/templates/build/App.java#L48
  4. David Benko 2017-10-18

    I'm experiencing this issue as well, SDK 6.2.2 Android 7.0 and 8.0
  5. Shuo Liang 2017-10-30

    Any update on this?
  6. Dongwoo Gim 2017-11-03

    Any update?
  7. Dongwoo Gim 2017-11-03

    Then exitOnClose set true, after close main window on Oreo.
       [DEBUG] Window: Window is closed normally.
       
       [INFO]  TiRootActivity: (main) [0,0] checkpoint, on root activity create, savedInstanceState: null
       [ERROR] TiAssetHelper: AssetManager is null, can't read asset: app.json
       [WARN]  TiApplication: (main) [225,225] Registering module with name already in use.
       [ERROR] TiAssetHelper: AssetManager is null, can't read asset: Resources/app.js
       [ERROR] TiAssetHelper: AssetManager is null, can't read asset: Resources/app.js
       
  8. Dongwoo Gim 2017-11-03

    And other situation on Oreo.
       [ERROR] TiAssetHelper: AssetManager is null, can't read asset: Resources/alloy/controllers/imageList.js
       
  9. Dongwoo Gim 2017-11-03

    And this error on Nougat.
       [INFO]  TiRootActivity: (main) [0,0] checkpoint, on root activity create, savedInstanceState: null
       [ERROR] TiAssetHelper: AssetManager is null, can't read asset: app.json
       [WARN]  TiApplication: (main) [147,147] Registering module with name already in use.
       [ERROR] TiAssetHelper: AssetManager is null, can't read asset: index.json
       [ERROR] TiExceptionHandler: (main) [24,171] ----- Titanium Javascript Runtime Error -----
       [ERROR] TiExceptionHandler: (main) [0,171] - In ti:/module.js:622,21
       [ERROR] TiExceptionHandler: (main) [0,171] - Message: Uncaught TypeError: Cannot use 'in' operator to search for 'Resources/alloy' in null
       [ERROR] TiExceptionHandler: (main) [0,171] - Source: 	return filename in fileIndex;
       [ERROR] V8Exception: Exception occurred at ti:/module.js:622: Uncaught TypeError: Cannot use 'in' operator to search for 'Resources/alloy' in null
       [INFO]  TiRootActivity: (main) [0,0] checkpoint, on root activity resume. activity = com.puruni.app.PuruniActivity@d558338
       
  10. Gary Mathews 2017-11-03

    [~engross] Thanks for the feedback, the AssetManager issue is solved by TIMOB-25324.
  11. Dongwoo Gim 2017-11-03

  12. Lokesh Choudhary 2017-11-15

    FR Passed. Waiting for merge to get enabled.
  13. Lokesh Choudhary 2017-11-15

    PR Merged.
  14. Lokesh Choudhary 2017-11-16

    Verified the fix in SDK 7.0.0.v20171115153702. Closing.

JSON Source