Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
New Contributor
areid
Posts: 8
Registered: ‎09-20-2012
My Device: Z10 LE, PlayBook
My Carrier: Wind

Running a webworks app with device in standby

I'm working on porting my Java app to Webworks for the BB10. The app collects geolocation data so it can be later plotted on a map. The problem I'm running into is that as soon as my device (dev alpha) locks the screen, the app is frozen so no more geolocation data is recieved, until I unlock the screen. I assume this means that the BB10 goes into standby as soon as the screen is locked. The max time before screen locking is 5 minutes, which is consistent with the max time before standby on the PlayBook. The idea is that the user can collect the location data for an hour or more, so this 5 minute limit is a show stopper. 

 

I've searched the forums and found some similar issues with webworks apps that play audio or perform an action based on an alarm, but no solutions. There is some mention of how to solve this using the <inactivePowerMode> tag in the bar descriptor for AIR apps, but nothing for Webworks.

 

This seems like a major limitation for webworks apps, I'm really hoping there is a solution out there. Aside from this issue, webworks seems to have all the API's I need. I'd hate to have to switch to a native app over this one issue.

 

If anyone has a solution or any info on how this might be resolved in webworks for BB10, I'd certainly appreciate the help.

 

Please use plain text.
BlackBerry Development Advisor
Nukul
Posts: 115
Registered: ‎06-06-2011
My Device: 9800
My Carrier: Rogers

Re: Running a webworks app with device in standby

 

You can do this today-

 

<rim:smileytongue:ermissions>
    <rim:smileytongue:ermit>run_when_backgrounded</rim:smileytongue:ermit>
</rim:smileytongue:ermissions>

 

 

https://developer.blackberry.com/html5/documentation/rim_permit_element.html

@nukulb
Please use plain text.
BlackBerry Development Advisor
Nukul
Posts: 115
Registered: ‎06-06-2011
My Device: 9800
My Carrier: Rogers

Re: Running a webworks app with device in standby


with proper formatting

 

<rim:permissions>
    <rim:permit>run_when_backgrounded</rim:permit>
</rim:permissions>

 

@nukulb
Please use plain text.
New Contributor
areid
Posts: 8
Registered: ‎09-20-2012
My Device: Z10 LE, PlayBook
My Carrier: Wind

Re: Running a webworks app with device in standby

Thanks for the reply. I tried that permission tag but it doesn't seem to change anything, with my test setup at least. I'm using a dev alpha with OS 10.0.9.388 and BB10 Webworks 1.0.2.9. Even with run_when_backgrounded in the config, as soon as the display dims the app stops getting the geolocation data until I unlock the screen. Strangely enough, it actualy does continue to run in the background if I switch to the home screen or another App, but that works with or without run_when_backgrounded.

 

It seems that run_when_backgrounded was added recently, anyone know what OS/webworks version is required to support it? I'd love to know whether my App is eventually going to work with a future software update, or if there is a different reason that the geolocation data is shutting off in standby which I need to address.

Please use plain text.
BlackBerry Development Advisor
Nukul
Posts: 115
Registered: ‎06-06-2011
My Device: 9800
My Carrier: Rogers

Re: Running a webworks app with device in standby

with run_when_backgrounded mode, the app will keep waking up every so often and getting the data.OS 10.0.9.388 should be sufficient for this.
@nukulb
Please use plain text.
New Contributor
areid
Posts: 8
Registered: ‎09-20-2012
My Device: Z10 LE, PlayBook
My Carrier: Wind

Re: Running a webworks app with device in standby

OK, I've done some more testing and can now see that run_when_backgrounded is having some effect, but not quite what I need. My app's own javascript does continue to run, eg if I set an interval timer, but unfortunately the geolocation updates stop as soon as the device display dims. I'm wondering whether the OS is putting the geolocation into standby for the entire device, or if it is just something with the webworks framework that isn't relaying the location updates. As soon as the device wakes the geolocation updates resume.

 

My simple test case to reproduce this is below. When the dev alpha is awake I get timer and location updates every few seconds, but  if the device goes into standby for a few minutes and I wake it up, I only see timer updates, no location updates for the period where the display was off. I really hope someone from RIM can help me out with this. Unless this issue is resolved, it seems pretty unlikely that anyone can write a useful GPS tracking app.

 

index.htm:
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html>
<head>
<meta name="viewport" content="initial-scale=1.0,width=device-width,user-scalable=no,target-densitydpi=device-dpi" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript">
            function appendMessage(message) {
                var d = new Date();
                var t = d.toLocaleTimeString();
                $("#content").append("<div>" + message + ": " + t + "</div>");
            }
            
            function setup(){
            navigator.geolocation.watchPosition(function(l){appendMessage("Location");}, null, null);
            setInterval(function(){appendMessage("Time");}, 5000);
            }
</script>
</head>
<body id="content" onload="setup();">
<div>Background test</div>
</body>
</html>
 
config:
 
<?xml version="1.0" encoding="utf-8"?>
<widget xmlns:rim="http://www.blackberry.com/ns/widgets" id="BackgroundTest" version="1.0.0.0" rim:header="RIM-Widget:rim/widget" xmlns="http://www.w3.org/ns/widgets">
  <rim:navigation mode="focus" />
  <name>Background Test</name>
  <description>Test of an app that runs in the background</description>
  <author>Adam</author>
  <icon src="icon.png" />
  <content src="index.htm" />
  <access uri="http://ajax.googleapis.com" subdomains="true" />
  <rim:permissions>  
    <rim:permit>run_when_backgrounded</rim:permit>
    <rim:permit>read_geolocation</rim:permit>
  </rim:permissions>
</widget>

 

 

 

 

 

Please use plain text.
Developer
n_jay144
Posts: 67
Registered: ‎09-05-2012
My Device: Z10 Red, PlayBook, DevAlpha C
My Carrier: Play

Re: Running a webworks app with device in standby

On my DevAlpha with run_when_backgrounded mode, the app keep working only if it is in full screen, even when device goes to sleep. However my app doesn't work when is minimized.

Please use plain text.
New Contributor
areid
Posts: 8
Registered: ‎09-20-2012
My Device: Z10 LE, PlayBook
My Carrier: Wind

Re: Running a webworks app with device in standby

The sample app I posted above runs when the App is minimized, or if I put another App like browser in the foreground on my dev alpha with OS 10.0.9.388. It also runs with the device in standby with the display off, but the geolocation updates stop in that case. It seems to me that the run_when_backgrounded is working as it should, it is more a case of some other OS services are shutting down in standby, but that is just my guess from playing around with test Apps.

Please use plain text.
Developer
n_jay144
Posts: 67
Registered: ‎09-05-2012
My Device: Z10 Red, PlayBook, DevAlpha C
My Carrier: Play

Re: Running a webworks app with device in standby

I just ported a simple countdown timer from PlayBook to BB10 DevAlpha and now I can see that script keeps going on when app is in background/minimized, however minimized screen is freezed up so I can't see elapsing time.

Please use plain text.