Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-27633] Android: Additional parameters in require cause app to crash

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2020-01-13T11:00:39.000+0000
Affected Version/sRelease 8.0.0
Fix Version/sRelease 9.0.0
ComponentsAndroid
Labelsandroid, engSchedule
ReporterJan Vennemann
AssigneeChristopher Williams
Created2019-11-26T19:19:27.000+0000
Updated2020-01-13T11:00:39.000+0000

Description

*Steps to reproduce the behavior*

Create a new JS files that can be required, for example test.js. The content doesn't matter

Require that JS file with an additional parameter

require('./test.js', true);

Run on Android

*Actual behavior* The app crashes during runtime with the following error:
[ERROR] TiExceptionHandler: (main) [157,157] ti:/module.js:596
[ERROR] TiExceptionHandler: 	context.sourceUrl = url;
[ERROR] TiExceptionHandler:                    ^
[ERROR] TiExceptionHandler: TypeError: Cannot create property 'sourceUrl' on boolean 'true'
[ERROR] TiExceptionHandler:     at Module._runScript (ti:/module.js:596:20)
[ERROR] TiExceptionHandler:     at Module.load (ti:/module.js:107:7)
[ERROR] TiExceptionHandler:     at Module.loadJavascriptText (ti:/module.js:453:9)
[ERROR] TiExceptionHandler:     at Module.loadAsFile (ti:/module.js:503:15)
[ERROR] TiExceptionHandler:     at Module.loadAsFileOrDirectory (ti:/module.js:425:20)
[ERROR] TiExceptionHandler:     at Module.require (ti:/module.js:255:17)
[ERROR] TiExceptionHandler:     at Module.global.Module.require (/ti.main.js:9505:34)
[ERROR] TiExceptionHandler:     at require (ti:/module.js:566:15)
[ERROR] TiExceptionHandler:     at /app.js:20:1
[ERROR] TiExceptionHandler:     at Module._runScript (ti:/module.js:608:9)
[ERROR] TiExceptionHandler:
[ERROR] TiExceptionHandler:     org.appcelerator.kroll.runtime.v8.V8Runtime.nativeRunModuleBytes(Native Method)
[ERROR] TiExceptionHandler:     org.appcelerator.kroll.runtime.v8.V8Runtime.doRunModuleBytes(V8Runtime.java:162)
[ERROR] TiExceptionHandler:     org.appcelerator.kroll.KrollRuntime.runModuleBytes(KrollRuntime.java:212)
[ERROR] TiExceptionHandler:     org.appcelerator.titanium.TiLaunchActivity.loadScript(TiLaunchActivity.java:101)
[ERROR] TiExceptionHandler:     org.appcelerator.titanium.TiRootActivity.loadScript(TiRootActivity.java:480)
[ERROR] TiExceptionHandler:     org.appcelerator.titanium.TiLaunchActivity.onResume(TiLaunchActivity.java:192)
[ERROR] TiExceptionHandler:     org.appcelerator.titanium.TiRootActivity.onResume(TiRootActivity.java:499)
[ERROR] TiExceptionHandler:     android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1355)
[ERROR] TiExceptionHandler:     android.app.Activity.performResume(Activity.java:7117)
[ERROR] TiExceptionHandler:     android.app.ActivityThread.performResumeActivity(ActivityThread.java:3556)
*Expected behavior* Additional parameter to require will be ignored. *Additional notes* If the file was required before without any additional parameters the require works as expected.
// This won't crash
require('./test');
require('./test', true);

Comments

  1. Jan Vennemann 2019-12-06

    [~gmathews] put up a PR https://github.com/appcelerator/titanium_mobile/pull/11378 for a possible solution and further discussion.
  2. Christopher Williams 2019-12-06

    WIP PR: https://github.com/appcelerator/titanium_mobile/pull/11380
  3. Christopher Williams 2019-12-16

    https://github.com/appcelerator/titanium_mobile/pull/11380
  4. Samir Mohammed 2020-01-10

    FR Passed, Waiting on Jenkins build.
  5. Christopher Williams 2020-01-10

    merged to master for 9.0.0
  6. Samir Mohammed 2020-01-13

    *Closing ticket*, fix verified in SDK Version 9.0.0.v20200110103446. Test and other information can be found at: https://github.com/appcelerator/titanium_mobile/pull/11380

JSON Source