Open evabishchevich opened 8 years ago
There is a problem that files in the same directory can't see each other. We get
ERROR thaliTape: uncaught exception, error: 'Error: Cannot find module './CoordinatedClient'', stack: 'Error: Cannot find module './CoordinatedClient' at $w._oldRes@module.js:802:9 at $w._resolveFilename@module.js:1771:1 at @/data/data/com.test.thalitest/files/www/jxcore/lib/CoordinatedTape.js:14:1 at $w.prototype._compile@module.js:621:8 at $w._extensions[".js"]@module.js:651:1 at $w.prototype.load@module.js:442:1' while running the app.
These files presented into a builded apk but on device files/www/jxcore folder is epmty. This folder was empty in previous versions also so it's default behaviour.
I'm going to investigate what cordova makes with assets during building process.
Needed files are in data/app/com.test.thalitest-1/base.apk. I installed our app on emulator, grabbed the apk and looked inside the apk.
Still fighting with this problem. There are a lot of error if I change order of require modules. Also I found out that we use old jxcore in our build script. I'm going to change that and check with 0.1.4
We have a work around for this so we will put it into backlog for now.
The work around didn't work. Currently it seems like we can't have require chains that are more than 4 deep. We need to fix this ASAP.
The problem doesn't show up on desktop but that is expected since in thaliTape.js, 'require('./CoordinatedTape');' is only called on mobile:
if (typeof jxcore === 'undefined' || typeof Mobile !== 'undefined') {
// On mobile, or outside of jxcore (some dev scenarios)
// we use the server-coordinated thaliTape.
exports = require('./CoordinatedTape');
exports.coordinated = true;
} else {
// On desktop we just use simple non-coordinated tape.
exports = require('./SimpleTape');
exports.coordinated = false;
}
Running the same code on Android using the standalone jxcore binary requires a few 'fixes' here and there, but overall it works and loads the CoordinatedClient without errors.
root@generic_x86:/data/local/tmp/thali/test # ../jx UnitTest_app.js
CoordinatedClient loaded
CoordinatedTape loaded
...
We can run jx runCoordinatedTests.js
with CoordinatedTape
on desktop.
@andrew-aladev
is it possible to run the Thali test app as a cordova app on desktop? Because running jx runCoordinatedTests.js
is not what I need in the sense that even on Android I can run it and it doesn't fail to load the CoordinatedClient module.
@enricogior So are the tests actually passing when you run them on Android? How many phones do you have?
At the current point of investigation, this seems a bug in the SpiderMonkey engine when running on ARM. The bug only shows up when using this code:
if (!Array.prototype.shuffle) {
Array.prototype.shuffle = function () {...};
}
Replacing existing Array.prototype methods works, adding a new one has the side effect of causing the 'require()' bug.
This is obviously awful but we don't currently have a good way of debugging on ARM what exactly is going on so for the short term we are going to remove prototypes on Array objects (and other system objects) but eventually we have to run this to ground.
See the comment in thaliproject/Thali_CordovaPlugin#1123 about js-polyfill. But @enricogior, if the ponyfill work around works then we should still keep this bug on the backlog but we can come back to it later and now with a test case (js-polyfill) that will apparently blow up on the desktop.
For now we have a work around so we'll have to put it into icebox.
Error!: Cannot find module './CoordinatedClient' Stack: [{"_fileName":"module.js","_functionName":"$w._oldRes","_lineNumber":"802","_columnNumber":"9","_msg":" at $w._oldRes@module.js:802:9"},{"_fileName":"module.js","_functionName":"$w._resolveFilename","_lineNumber":"1771","_columnNumber":"1","_msg":" at $w._resolveFilename@module.js:1771:1"},{"_fileName":"module.js","_functionName":"$w._load","_lineNumber":"362","_columnNumber":"4","_msg":" at $w._load@module.js:362:4"},{"_fileName":"module.js","_functionName":"$w.prototype.require","_lineNumber":"477","_columnNumber":"8","_msg":" at $w.prototype.require@module.js:477:8"},{"_fileName":"module.js","_functionName":"require","_lineNumber":"495","_columnNumber":"8","_msg":" at require@module.js:495:8"},{"_fileName":"/data/data/com.test.thalitest/files/www/jxcore/lib/CoordinatedTape.js","_functionName":"","_lineNumber":"12","_columnNumber":"25","_msg":" at @/data/data/com.test.thalitest/files/www/jxcore/lib/CoordinatedTape.js:12:25"}] 09-14 18:16:51.282 16527-16612/com.test.thalitest I/jxcore-log: ERROR testUtils: uncaught exception, error: 'Error: Cannot find module './CoordinatedClient'', stack: 'Error: Cannot find module './CoordinatedClient' at $w._oldRes@module.js:802:9 at $w._resolveFilename@module.js:1771:1 at $w._load@module.js:362:4 at $w.prototype.require@module.js:477:8 at require@module.js:495:8 at @/data/data/com.test.thalitest/files/www/jxcore/lib/CoordinatedTape.js:12:25' 09-14 18:16:51.282 16527-16612/com.test.thalitest I/jxcore-log: ERROR testUtils: _TEST_LOGGER:[PROCESS_ON_EXIT_FAILED]_ 09-14 18:16:51.282 16527-16612/com.test.thalitest E/jxcore-log: Error: 09-14 18:16:51.282 16527-16612/com.test.thalitest E/jxcore-log: Cannot find module './CoordinatedClient' 09-14 18:16:51.282 16527-16612/com.test.thalitest E/jxcore-log: (module.js 802:9)