Welcome to the Official BlackBerry® Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Web and WebWorks Development

Reply
Developer
shnuffy
Posts: 268
Registered: 08-19-2009

Potential bug - App (and device) freezes on bringToForeground() if JS alert is called while app is in background

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.

Please use plain text.
BlackBerry Development Advisor
oros
Posts: 410
Registered: 04-12-2010
My Carrier: Rogers

Re: Potential bug - App (and device) freezes on bringToForeground() if JS alert is called while app is in background

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

Erik Oros
BlackBerry Development Advisor
@WaterlooErik
Please use plain text.
Developer
shnuffy
Posts: 268
Registered: 08-19-2009

Re: Potential bug - App (and device) freezes on bringToForeground() if JS alert is called while app is in background

[ Edited ]

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?). 

Please use plain text.
BlackBerry Development Advisor
oros
Posts: 410
Registered: 04-12-2010
My Carrier: Rogers

Re: Potential bug - App (and device) freezes on bringToForeground() if JS alert is called while app is in background

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

Erik Oros
BlackBerry Development Advisor
@WaterlooErik
Please use plain text.
Developer
shnuffy
Posts: 268
Registered: 08-19-2009

Re: Potential bug - App (and device) freezes on bringToForeground() if JS alert is called while app is in background

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. 

Please use plain text.
BlackBerry Development Advisor
oros
Posts: 410
Registered: 04-12-2010
My Carrier: Rogers

Re: Potential bug - App (and device) freezes on bringToForeground() if JS alert is called while app is in background

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

Erik Oros
BlackBerry Development Advisor
@WaterlooErik
Please use plain text.