RE: onNativeReady and FirefoxOS
I took an older snapshot of the repo that we had working on the FxOS simulator and ran it in the current FxOS simulator. Got the same result as Piotr. From: f...@adobe.com To: dev@cordova.apache.org Date: Mon, 1 Jul 2013 12:43:35 -0700 Subject: Re: onNativeReady and FirefoxOS Hey Piotr, Most Cordova platforms include two stacks: a native and a web stack, or side, or context. For example, Android and iOS implement various bits of functionality (like access to contacts data) by bridging into the native SDK APIs and making native calls, then sending messages back into the web context to return the requested data. It is up to each platform's implementation to expose an `exec` method, which is an interface between the web and native contexts. It is a message-passing mechanism. You invoke it from JavaScript, passing in a few arguments that map themselves to native classes/methods, as well as success and failure callbacks. Cordova will then marshall these `exec` calls to the native context, make sure the message gets passed into the appropriate native API class and method, and, once complete, makes sure the appropriate success or failure callback gets invoked back in the web context. More information on this method can be found in our Plugin Development guide [1]. Some Cordova platforms, like BlackBerry, FxOS and Tizen, are purely web-based, and thus have no native side. Instead, these platforms already have JavaScript-based device APIs exposed. For most of these platforms, the `exec` method doesn't marshall to a native context but instead simply invokes the appropriate JavaScript method provided by the platform. This keeps cordova's `exec` abstraction intact and thus enables development of Cordova plugins to be done in a cross-platform manner: JavaScript serves as the abstraction. Firefox OS should be doing something similar to BlackBerry or Tizen. For one example, BlackBerry has a short list of purely-JavaScript plugins [2], and if the `exec` method invocation detects that an exec call is for one of these plugins, it will simply invoke that JS-only plugin's method as appropriate [3]. Similarly, Tizen has an exec method implementation that simply invokes a manager class [4], which in turn literally translates into a purely JavaScript require call for the particular service+action invoked and lets that JavaScript method do all of the work [5]. In my opinion, FxOS' implementation will mirror Tizen's closely, since all of FxOS APIs are available in JavaScript. Perhaps there is a native component to FxOS (I am not super familiar with FxOS internals) down the road, where Cordova users will want to invoke some FxOS-specific low-level APIs through some mechanism. Hopefully that can help you out. Feel free to post more q's or contact me directly if there's anything I can help with. [1] http://cordova.apache.org/docs/en/2.9.0/guide_plugin-development_index.md.h tml#Plugin%20Development%20Guide [2] https://github.com/apache/cordova-js/blob/master/lib/blackberry10/exec.js#L 23-L26 [3] https://github.com/apache/cordova-js/blob/master/lib/blackberry10/exec.js#L 43-L45 [4] https://github.com/apache/cordova-js/blob/master/lib/tizen/exec.js#L63 [5] https://github.com/apache/cordova-js/blob/master/lib/tizen/plugin/tizen/man ager.js#L26 On 7/1/13 10:05 AM, Piotr Zalewa pzal...@mozilla.com wrote: OK, now It's stuck on events which are waiting for initialization (in array channel.deviceReadyChannelsArray) https://github.com/apache/cordova-firefoxos/blob/master/lib/cordova.firefo xos.js#L5976 - onCordovaReady and onCordovaConnectionReady. onCordovaReady is fired, but onCordovaConnectionReady is not. The connection ready event is fired in https://github.com/apache/cordova-firefoxos/blob/master/lib/cordova.firefo xos.js#L5379-L5410 but this code isn't run and hence it's not called when cordova ready is fired. Any solution for this? Piotr - Original Message - From: Gord Tanner gtan...@gmail.com To: dev@cordova.apache.org Sent: Tuesday, June 25, 2013 5:38:01 PM Subject: Re: onNativeReady and FirefoxOS I could have swore there was one at one point ;) but it is going to look exactly like the webos one [1] [1] - https://git-wip-us.apache.org/repos/asf?p=cordova-js.git;a=blob_plain;f=li b/scripts/bootstrap-webos.js;hb=HEAD On Tue, Jun 25, 2013 at 10:52 AM, Andrew Grieve agri...@chromium.orgwrote: likely you want to add a bootstrap.firefoxos.js file On Tue, Jun 25, 2013 at 3:40 AM, Piotr Zalewa pzal...@mozilla.com wrote: Hi, Here is me again. I commented out the reinstantiating window.navigator to make it not throw SecurityError under FxOS. I then realized the 'deviceready' isn't fired. It should be fired in https://github.com/apache/cordova-firefoxos/blob/master/lib/cordova.firef oxos.js#L5977afterchannel.onDOMContentLoaded, channel.onNativeReady
Re: onNativeReady and FirefoxOS
OK, now It's stuck on events which are waiting for initialization (in array channel.deviceReadyChannelsArray) https://github.com/apache/cordova-firefoxos/blob/master/lib/cordova.firefoxos.js#L5976 - onCordovaReady and onCordovaConnectionReady. onCordovaReady is fired, but onCordovaConnectionReady is not. The connection ready event is fired in https://github.com/apache/cordova-firefoxos/blob/master/lib/cordova.firefoxos.js#L5379-L5410 but this code isn't run and hence it's not called when cordova ready is fired. Any solution for this? Piotr - Original Message - From: Gord Tanner gtan...@gmail.com To: dev@cordova.apache.org Sent: Tuesday, June 25, 2013 5:38:01 PM Subject: Re: onNativeReady and FirefoxOS I could have swore there was one at one point ;) but it is going to look exactly like the webos one [1] [1] - https://git-wip-us.apache.org/repos/asf?p=cordova-js.git;a=blob_plain;f=lib/scripts/bootstrap-webos.js;hb=HEAD On Tue, Jun 25, 2013 at 10:52 AM, Andrew Grieve agri...@chromium.orgwrote: likely you want to add a bootstrap.firefoxos.js file On Tue, Jun 25, 2013 at 3:40 AM, Piotr Zalewa pzal...@mozilla.com wrote: Hi, Here is me again. I commented out the reinstantiating window.navigator to make it not throw SecurityError under FxOS. I then realized the 'deviceready' isn't fired. It should be fired in https://github.com/apache/cordova-firefoxos/blob/master/lib/cordova.firefoxos.js#L5977afterchannel.onDOMContentLoaded, channel.onNativeReady, channel.onPluginsReady. onDOMContentLoaded and onPluginsReady are fired, but onNativeReady is not. The only place in this file which is related to this event is this: https://github.com/apache/cordova-firefoxos/blob/master/lib/cordova.firefoxos.js#L5954 // _nativeReady is global variable that the native side can set // to signify that the native code is ready. It is a global since // it may be called before any cordova JS is ready. if (window._nativeReady) { channel.onNativeReady.fire(); } Is this event not fired because of my change to cordova-firefoxos.js (commenting out https://github.com/apache/cordova-firefoxos/blob/master/lib/cordova.firefoxos.js#L5945 )? Please help zalun PS. There is also an issue later on with onCordovaConnectionReady (but I forced onNativeReady before, so too many variables to play)
Re: onNativeReady and FirefoxOS
Hey Piotr, Most Cordova platforms include two stacks: a native and a web stack, or side, or context. For example, Android and iOS implement various bits of functionality (like access to contacts data) by bridging into the native SDK APIs and making native calls, then sending messages back into the web context to return the requested data. It is up to each platform's implementation to expose an `exec` method, which is an interface between the web and native contexts. It is a message-passing mechanism. You invoke it from JavaScript, passing in a few arguments that map themselves to native classes/methods, as well as success and failure callbacks. Cordova will then marshall these `exec` calls to the native context, make sure the message gets passed into the appropriate native API class and method, and, once complete, makes sure the appropriate success or failure callback gets invoked back in the web context. More information on this method can be found in our Plugin Development guide [1]. Some Cordova platforms, like BlackBerry, FxOS and Tizen, are purely web-based, and thus have no native side. Instead, these platforms already have JavaScript-based device APIs exposed. For most of these platforms, the `exec` method doesn't marshall to a native context but instead simply invokes the appropriate JavaScript method provided by the platform. This keeps cordova's `exec` abstraction intact and thus enables development of Cordova plugins to be done in a cross-platform manner: JavaScript serves as the abstraction. Firefox OS should be doing something similar to BlackBerry or Tizen. For one example, BlackBerry has a short list of purely-JavaScript plugins [2], and if the `exec` method invocation detects that an exec call is for one of these plugins, it will simply invoke that JS-only plugin's method as appropriate [3]. Similarly, Tizen has an exec method implementation that simply invokes a manager class [4], which in turn literally translates into a purely JavaScript require call for the particular service+action invoked and lets that JavaScript method do all of the work [5]. In my opinion, FxOS' implementation will mirror Tizen's closely, since all of FxOS APIs are available in JavaScript. Perhaps there is a native component to FxOS (I am not super familiar with FxOS internals) down the road, where Cordova users will want to invoke some FxOS-specific low-level APIs through some mechanism. Hopefully that can help you out. Feel free to post more q's or contact me directly if there's anything I can help with. [1] http://cordova.apache.org/docs/en/2.9.0/guide_plugin-development_index.md.h tml#Plugin%20Development%20Guide [2] https://github.com/apache/cordova-js/blob/master/lib/blackberry10/exec.js#L 23-L26 [3] https://github.com/apache/cordova-js/blob/master/lib/blackberry10/exec.js#L 43-L45 [4] https://github.com/apache/cordova-js/blob/master/lib/tizen/exec.js#L63 [5] https://github.com/apache/cordova-js/blob/master/lib/tizen/plugin/tizen/man ager.js#L26 On 7/1/13 10:05 AM, Piotr Zalewa pzal...@mozilla.com wrote: OK, now It's stuck on events which are waiting for initialization (in array channel.deviceReadyChannelsArray) https://github.com/apache/cordova-firefoxos/blob/master/lib/cordova.firefo xos.js#L5976 - onCordovaReady and onCordovaConnectionReady. onCordovaReady is fired, but onCordovaConnectionReady is not. The connection ready event is fired in https://github.com/apache/cordova-firefoxos/blob/master/lib/cordova.firefo xos.js#L5379-L5410 but this code isn't run and hence it's not called when cordova ready is fired. Any solution for this? Piotr - Original Message - From: Gord Tanner gtan...@gmail.com To: dev@cordova.apache.org Sent: Tuesday, June 25, 2013 5:38:01 PM Subject: Re: onNativeReady and FirefoxOS I could have swore there was one at one point ;) but it is going to look exactly like the webos one [1] [1] - https://git-wip-us.apache.org/repos/asf?p=cordova-js.git;a=blob_plain;f=li b/scripts/bootstrap-webos.js;hb=HEAD On Tue, Jun 25, 2013 at 10:52 AM, Andrew Grieve agri...@chromium.orgwrote: likely you want to add a bootstrap.firefoxos.js file On Tue, Jun 25, 2013 at 3:40 AM, Piotr Zalewa pzal...@mozilla.com wrote: Hi, Here is me again. I commented out the reinstantiating window.navigator to make it not throw SecurityError under FxOS. I then realized the 'deviceready' isn't fired. It should be fired in https://github.com/apache/cordova-firefoxos/blob/master/lib/cordova.firef oxos.js#L5977afterchannel.onDOMContentLoaded, channel.onNativeReady, channel.onPluginsReady. onDOMContentLoaded and onPluginsReady are fired, but onNativeReady is not. The only place in this file which is related to this event is this: https://github.com/apache/cordova-firefoxos/blob/master/lib/cordova.firef oxos.js#L5954 // _nativeReady is global variable that the native side can set // to signify that the native code is ready. It is a global since
onNativeReady and FirefoxOS
Hi, Here is me again. I commented out the reinstantiating window.navigator to make it not throw SecurityError under FxOS. I then realized the 'deviceready' isn't fired. It should be fired in https://github.com/apache/cordova-firefoxos/blob/master/lib/cordova.firefoxos.js#L5977 after channel.onDOMContentLoaded, channel.onNativeReady, channel.onPluginsReady. onDOMContentLoaded and onPluginsReady are fired, but onNativeReady is not. The only place in this file which is related to this event is this: https://github.com/apache/cordova-firefoxos/blob/master/lib/cordova.firefoxos.js#L5954 // _nativeReady is global variable that the native side can set // to signify that the native code is ready. It is a global since // it may be called before any cordova JS is ready. if (window._nativeReady) { channel.onNativeReady.fire(); } Is this event not fired because of my change to cordova-firefoxos.js (commenting out https://github.com/apache/cordova-firefoxos/blob/master/lib/cordova.firefoxos.js#L5945)? Please help zalun PS. There is also an issue later on with onCordovaConnectionReady (but I forced onNativeReady before, so too many variables to play)
Re: onNativeReady and FirefoxOS
likely you want to add a bootstrap.firefoxos.js file On Tue, Jun 25, 2013 at 3:40 AM, Piotr Zalewa pzal...@mozilla.com wrote: Hi, Here is me again. I commented out the reinstantiating window.navigator to make it not throw SecurityError under FxOS. I then realized the 'deviceready' isn't fired. It should be fired in https://github.com/apache/cordova-firefoxos/blob/master/lib/cordova.firefoxos.js#L5977after channel.onDOMContentLoaded, channel.onNativeReady, channel.onPluginsReady. onDOMContentLoaded and onPluginsReady are fired, but onNativeReady is not. The only place in this file which is related to this event is this: https://github.com/apache/cordova-firefoxos/blob/master/lib/cordova.firefoxos.js#L5954 // _nativeReady is global variable that the native side can set // to signify that the native code is ready. It is a global since // it may be called before any cordova JS is ready. if (window._nativeReady) { channel.onNativeReady.fire(); } Is this event not fired because of my change to cordova-firefoxos.js (commenting out https://github.com/apache/cordova-firefoxos/blob/master/lib/cordova.firefoxos.js#L5945 )? Please help zalun PS. There is also an issue later on with onCordovaConnectionReady (but I forced onNativeReady before, so too many variables to play)
Re: onNativeReady and FirefoxOS
I could have swore there was one at one point ;) but it is going to look exactly like the webos one [1] [1] - https://git-wip-us.apache.org/repos/asf?p=cordova-js.git;a=blob_plain;f=lib/scripts/bootstrap-webos.js;hb=HEAD On Tue, Jun 25, 2013 at 10:52 AM, Andrew Grieve agri...@chromium.orgwrote: likely you want to add a bootstrap.firefoxos.js file On Tue, Jun 25, 2013 at 3:40 AM, Piotr Zalewa pzal...@mozilla.com wrote: Hi, Here is me again. I commented out the reinstantiating window.navigator to make it not throw SecurityError under FxOS. I then realized the 'deviceready' isn't fired. It should be fired in https://github.com/apache/cordova-firefoxos/blob/master/lib/cordova.firefoxos.js#L5977afterchannel.onDOMContentLoaded, channel.onNativeReady, channel.onPluginsReady. onDOMContentLoaded and onPluginsReady are fired, but onNativeReady is not. The only place in this file which is related to this event is this: https://github.com/apache/cordova-firefoxos/blob/master/lib/cordova.firefoxos.js#L5954 // _nativeReady is global variable that the native side can set // to signify that the native code is ready. It is a global since // it may be called before any cordova JS is ready. if (window._nativeReady) { channel.onNativeReady.fire(); } Is this event not fired because of my change to cordova-firefoxos.js (commenting out https://github.com/apache/cordova-firefoxos/blob/master/lib/cordova.firefoxos.js#L5945 )? Please help zalun PS. There is also an issue later on with onCordovaConnectionReady (but I forced onNativeReady before, so too many variables to play)