DEVELOPERS BLOG

Ensure Your WebWork APIs Function in BlackBerry 10.1 and 10.2: Updates and Best Practice

WEB DEVELOPMENT / 09.16.13 / kjwallis

Today we wanted to share some information and advice around BlackBerry 10 and WebWorks development that may affect your application. As always, please let us know if you have any questions in the comments below.

If your application uses existing sample code for BlackBerry 10 WebWorks to initialize the toolkit, it may not work in future releases of BlackBerry 10. In the latest maintenance release of BlackBerry 10.1 and the upcoming release of BlackBerry 10.2, we have seen reports that the framework may not initialize if the code provided from the sample was used.

The code in the sample assigns a listener to the webworksready event on the document object, but it does so before waiting for the window load event. This creates a race condition where the document object may not yet exist. We recommend that you inspect your initialization code to ensure that you are waiting for the window load event before accessing the document object otherwise a JavaScript error could occur.

Example code showing the proper best practice approach can be found here. Since the issue is a race condition, it may occur intermittently depending on many factors on the user’s device. You can prevent this failure by ensuring that your initialization code follows this best practice.

Have questions? The BlackBerry Developer Relations team is always on hand to guide you through the development process on this blog, Twitter and Facebook!

About kjwallis