cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "John Little (JIRA)" <>
Subject [jira] [Commented] (CB-8830) application locks up when run with "cordova serve"
Date Thu, 09 Apr 2015 13:59:12 GMT


John Little commented on CB-8830:

Hmm this was a little more complicated than I first thought.
I have had to put a try/catch round the first use of the Windows object in the DeviceProxy.js
for both windows and windows8. This allows the detection of the exception and allows the software
to call the fail function.
I then modified the failed function to set "me.available = false" and call ";"
which alllows the software to continue.
I also removed the "utils.alert" call, as I didn't need it.

These modifications will allow the plugin to work when using "cordova serve" in windows mode.

> application locks up when run with "cordova serve"
> --------------------------------------------------
>                 Key: CB-8830
>                 URL:
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Plugin Device
>         Environment: windows 8.1 and OSx
> Cordova 4.3.0
>            Reporter: John Little
> When the Device plugin is added to a cordova project and the software is tested using
the "cordova serve" option (run a local web server for testing with a browser) the software
locks up and fails to start.
> There is an exception in the Device plugin as below
> Exception calling native with command :: Device :: getDeviceInfo ::exception=ReferenceError:
'Windows' is undefined
> This is not supprising as there is no device, it's just serving the app through a web
> However the software locks up because the "onCordovaInfoReady" is never fired.
> A simple fix is to modify the device.js file as below
>    channel.onCordovaReady.subscribe(function() {
>         var callFailed = true;  // NEW assume the getInfo fails
>         me.getInfo(function(info) {
>             callFailed = false;  // NEW it's all good
>             //ignoring info.cordova returning from native, we should use value from cordova.version
defined in cordova.js
>             //TODO: CB-5105 native implementations should not return info.cordova
>             var buildLabel = cordova.version;
>             me.available = true;
>             me.platform = info.platform;
>             me.version = info.version;
>             me.uuid = info.uuid;
>             me.cordova = buildLabel;
>             me.model = info.model;
>             me.manufacturer = info.manufacturer || 'unknown';
>   ;
>         },function(e) {
>             // NEW failure will be handled below
>             utils.alert("[ERROR] Error initializing Cordova: " + e);
>         });
>       // new code to stop the system locking up
>       if(callFailed) {
>         me.available = false;    // NEW can't be available as getInfo failed
>;   // NEW fire event to allow system to work
>         }
> With this mod inplace the software will work, obviously the device information is invalid.

This message was sent by Atlassian JIRA

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message