Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-23301] Windows: Ti.API.log doesn't handle single argument

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2016-05-03T17:48:31.000+0000
Affected Version/sn/a
Fix Version/sRelease 5.3.0
ComponentsWindows
Labelsqe-5.3.0
ReporterNazmus Salahin
AssigneeChristopher Williams
Created2016-05-02T13:39:49.000+0000
Updated2016-05-09T20:53:28.000+0000

Description

Hello, I have found that Ti.Locale.setLanguage works on Android but not on Windows Phone. *Steps:* 1. Create a default classic project. 2. Replace app.js code with following.

var win1 = Titanium.UI.createWindow({  
    title:'Tab 1',
    backgroundColor:'#fff'
});


win1.open();

var lan=Ti.Locale.getCurrentLanguage();
Ti.API.log("Initial Language: "+lan);
Ti.Locale.setLanguage("fr");
lan=Ti.Locale.getCurrentLanguage();
Ti.API.log("Language Changed To: "+lan);
3. Build and run the app. 4.On Android following console log is produced.
[INFO] :   Initial Language: en
[INFO] :   Language Changed To: fr
But on Windows Phone the app fails to run and following error log is produced.
[ERROR] :  Application Error: {
[ERROR] :    "line": 2,
[ERROR] :    "column": 10,
[ERROR] :    "message": "Error while require(/app) invalid vector<T> subscript",
[ERROR] :    "native_stack": [
[ERROR] :      "JSExportClass<class Titanium::GlobalObject>::CallNamedFunction"
[ERROR] :    ]
[ERROR] :  }
Thanks *Environment*: *Device info:* Nexus7 (android 6.0.1) , Microsoft Lumia 640 (Windows Phone 8.1) *Node.js Version:* 0.12.7 *npm Version:* 2.11.3 *Titanium SDKs:* 5.2.2.GA and 5.2.1.GA *Java Development Kit Version:* 1.8.0_73 *Titanium CLI Version:* 5.0.5 *Appcelerator CLI Version:* 5.2.2 *Appcelerator Studio:* 4.5.0

Comments

  1. Christopher Williams 2016-05-02

    My best guess is that in the Ti.Locale constructor where we do:
       currentLocale__  = TitaniumWindows::Utility::ConvertString(GlobalizationPreferences::Languages->GetAt(0));
       
    That's failing because GlobalizationPreferences::Languages is empty?
  2. Christopher Williams 2016-05-02

    https://github.com/appcelerator/titanium_mobile_windows/pull/656 https://github.com/appcelerator/titanium_mobile_windows/pull/657
  3. Christopher Williams 2016-05-03

    The problem is Ti.API.log.
       var win1 = Titanium.UI.createWindow({  
           title:'Tab 1',
           backgroundColor:'#fff'
       });
        
        
       win1.open();
        
       var lan = Ti.Locale.currentLanguage;
       Ti.API.info("Initial Language: " + lan);
       
    This works https://docs.appcelerator.com/platform/latest/#!/api/Titanium.API-method-log level is not working correctly on Windows
  4. Christopher Williams 2016-05-03

    Hmm, I'm not even sure this is valid JS here. The Ti.API.log method takes two arguments, but in this sample there's only one arg. That's the likely cause of the issue here. I would say we should better handle this single arg call, though. It looks like Android handles this case and assume INFO level logging when we only get a single argument, and that the argument is the message. See https://github.com/appcelerator/titanium_mobile/blob/415bd6c66dcc55b1a59a59574f3babd3c3a84ede/android/runtime/v8/src/native/modules/APIModule.cpp#L188
  5. Josh Longton 2016-05-09

    Verified as fixed Tested on: Nokia Lumia 928 (8.1) Windows Simulator (8.1) Microsoft Lumia 640 (10) Windows Simulator (10) Windows 10 Studio: 4.6.0.201605030516 Ti SDK: 5.3.0.v20160509074015 Appc NPM: 4.2.5-5 App CLI: 5.3.0-44 Node v4.4.3 *Closing Ticket.*

JSON Source