[TIMOB-18770] HAL: Variables using unicode characters cause Application Error
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | None |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2015-07-14T23:16:31.000+0000 |
Affected Version/s | Release 4.1.0 |
Fix Version/s | Release 4.1.0 |
Components | Hyperloop, Windows |
Labels | HAL, JavaScriptCore |
Reporter | Fokke Zandbergen |
Assignee | Gary Mathews |
Created | 2015-03-31T14:48:35.000+0000 |
Updated | 2017-03-16T21:55:43.000+0000 |
Description
When you use a special unicode character in a variable name (which is perfectly fine on iOS and Android and valid JS) the application will crash.
Test case
var φ = 'hello world';
Ti.UI.createWindow({
backgroundColor: "white"
}).open();
Crash
[ERROR] Application Error: {
[ERROR] "message": "Error while require(./app) Invalid character '\\u0966'",
[ERROR] "native_stack": [
[ERROR] "JSExportClass<class Titanium::GlobalObject>::CallNamedFunction"
[ERROR] ],
[ERROR] "stack": "require@[native code]\nglobal code",
[ERROR] "line": 2
[ERROR] }
Kota, can you please take a look when you get a moment?
Confirmed that this issue originally came from JavaScriptCore C API itself on Windows. Thus HAL on Windows can not handle this well. For instance following code should return "hello, world" string but on Windows it returns "undefined". I'm expecting there's some issue handling UTF-8 string on JavaScriptCore Windows but I'm not sure where it is and how to fix this.
Confirmed that the character
φ
is successfully converted into valid UTF-8 bytes (0xcf86) and passed to JSC functions. It means the issues are inside JavaScriptCore so in order to fix this issue we need to update JavaScriptCore. may be related: https://github.com/WebKit/webkit/commits/master/Source/JavaScriptCore/parser/Lexer.cppThis may the commit that fixes the issue in webkit/JSC? https://github.com/WebKit/webkit/commit/2eb5f4de2fb20e7dddaba89da5118e84d71d82c5#diff-0af0b457165c27ee7ef19b92709c2df1
While trying to apply recent changes around [JavaScriptCore Lexer | https://github.com/WebKit/webkit/commit/2eb5f4de2fb20e7dddaba89da5118e84d71d82c5#diff-0af0b457165c27ee7ef19b92709c2df1], I found that recent JavaScriptCore is trying to eliminates use of
WTF::Unicode
but instead use ICU directly. The problem here is that our JavaScriptCore for Windows is relying on customWTF::Unicode
handler forwchar_t
which is built specifically for Windows, which doesn't depend on ICU. That's why we can't merge latest changes around Lexer as it is. So the actual issue now is that, it looks like we actually didn't implement Unicode detection in our customWTF::Unicode
handler. See [WTF/wtf/unicode/wchar/UnicodeWchar.cpp](https://github.com/appcelerator/webkit/blob/javascriptcore-wp8.1/Source/WTF/wtf/unicode/wchar/UnicodeWchar.cpp#L33), we can see someFIXME: implement
comment there. I would assume at least we should implement these to handle Unicode correctly to make JavaScriptCore Lexer work well.https://github.com/appcelerator/webkit/pull/5
Original issue in JavaScriptCore is already fixed by [webkit#PR5](https://github.com/appcelerator/webkit/pull/5). Waiting for TIMOB-18948 to be done.
Reopening ticket, when building with: Windows 8.1 Appc CLI (NPM): 4.1.0 Appc CLI (Registry): 4.1.0 Ti SDK: 4.1.0.GA, 4.2.0.v20150710092422 When using the code attached I still see the error
This is because the build server for
titanium_mobile_windows
is using an oldJavaScriptCore
build to compile the SDK. [titanium_mobile_windows/Tools/Scripts/setup.js](https://github.com/appcelerator/titanium_mobile_windows/blob/master/Tools/Scripts/setup.js#L33) We should be using [JavaScriptCore-Windows-1433795599.zip](http://studio-jenkins.appcelerator.org/job/JavaScriptCore/lastSuccessfulBuild/artifact/dist/JavaScriptCore-Windows-1433795599.zip)PR: https://github.com/appcelerator/titanium_mobile_windows/pull/373
Closing ticket as fixed.