02-09-2012 10:41 AM
Reproduced on Bold 9700, OS 5.0. WebWorks SDK 2.2.
In my onPush(data) function, which is called when a push is received, I had the following code:
try
{
alert('Push received');
//do stuff with data
return 1;
}
catch(err)
{
//error
}
I don't allow the app itself to exit, just get sent to background. If the app was minimized and the user received a push, as soon as they attempted to open the app their device would freeze requiring a battery pull. By changing the code to the following, the issue was no longer reproducible:
try
{
if (blackberry.system.isForeground)
{
alert('Push received');
}
//do stuff with data
return 1;
}
catch(err)
{
//error
}
These are the types of issues that can make WebWorks development very fickle and difficult to fully test.
02-14-2012 06:41 PM
Hi shnuffy,
That's quite the interesting find. In my experience, alerts while an app is in the background simply will not be displayed and has been a limitation for a while (making innerHTML updates of a specific div my go-to live-logging approach.)
Though your sample-case certainly seems to indicate the alert is holding it up. Do you happen to have the full OS version for the 5.0 device/simulator?
Also, would you be able to test this with SDK 2.3 by chance? Is there a specific reason you are using SDK 2.2?
Erik Oros
BlackBerry Development Advisor
02-15-2012 11:25 AM - last edited on 02-15-2012 11:26 AM
There's a 2.3 now?! I'll download this tonight but I won't be able to test since it's a non-technical user far, far away that was seeing this issue. I may be able to get the full OS version.
It has generally been my experience that alerts are simply ignored when the app is in the background as well. I suspect, if this is actually the issue as it appears to be for me, that it has to do with the combination of being within a try block or because it's invoked in the the onPush function (a "special" function?).
02-15-2012 02:55 PM
I would sooner agree that it might have to do with the onPush function since the method of being invoked is different than the regular user-invoked JavaScript. But this is speculation at best, I'm not sure what the primary cause here is.
Are you doing anything complex within your catch? I'm still wary of expecting alert to throw an exception (even with the app in background) but if so, perhaps something there is contributing further to the freeze.
I haven't been able to produce this in my environment, but I'll keep trying some more.
Erik Oros
BlackBerry Development Advisor
02-15-2012 04:27 PM
It was only a problem on this specific device, other 9700's running OS 5 (maybe different versions) didn't exhibit this. The problematic device is likely on a BES, but otherwise has data access and it works with the fix described above.
02-15-2012 04:31 PM
I see. I'm inclined to think OS related then, but in all honesty it's such a specific and odd scenario that I'm just not sure (and now understand my difficulty in repro'ing.) Good work in hashing out the workaround though!
Erik Oros
BlackBerry Development Advisor