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
Contributor
Posts: 18
Registered: ‎03-08-2011
My Device: Not Specified

Playbook Simulator / Webworks bug

I think I've stumbled onto a bug which is either on the playbook simulator or the webworks SDK.

 

When using the javascript Math.random() function, it seems to always generate the same sequence of numbers every time I start my application.

 

I don't remember having this problem in the previous version of the simulator / SDK, so I think it was introduced in the latest versions (the April 19th releases of the simulator and SDK).

 

The random function works fine when I test my code in a web browser, it it definately seems like a bug in the playbook simulator or SDK.

 

Where would we go about filing bugs? I don't think I've seen this option anywhere.

Developer
Posts: 160
Registered: ‎03-12-2011
My Device: PlayBook♥
My Carrier: eplus

Re: Playbook Simulator / Webworks bug

I had an app with math.random running on the old SDK and it wasn't a problem.
----------
Please give free Likes if I helped you out! :smileyhappy:
Contributor
Posts: 18
Registered: ‎03-08-2011
My Device: Not Specified

Re: Playbook Simulator / Webworks bug

yeah... I believe it worked fine in the old SDK (can't verify now).

I suspect the problem was introduced in the new SDK or simulator.
Developer
Posts: 160
Registered: ‎03-12-2011
My Device: PlayBook♥
My Carrier: eplus

Re: Playbook Simulator / Webworks bug

Just tested it for you.
Working fine.. maybe you post the part of the code an I'll have a look at it.
----------
Please give free Likes if I helped you out! :smileyhappy:
Contributor
Posts: 18
Registered: ‎03-08-2011
My Device: Not Specified

Re: Playbook Simulator / Webworks bug

Well... there isn't much to my code... I pretty much just have:

var value = Math.random();

and I print out this value.

Whenever I start my app... I get the same sequence of numbers now.
Developer
Posts: 160
Registered: ‎03-12-2011
My Device: PlayBook♥
My Carrier: eplus

Re: Playbook Simulator / Webworks bug

Don't forget to set your min/max value.

Something like this should work just fine:

 

function GetRandom( min, max ) {
	if( min > max ) {
		return( -1 );
	}
	if( min == max ) {
		return( min );
	}
 
        return( min + parseInt( Math.random() * ( max-min+1 ) ) );
}
----------
Please give free Likes if I helped you out! :smileyhappy:
Contributor
Posts: 18
Registered: ‎03-08-2011
My Device: Not Specified

Re: Playbook Simulator / Webworks bug

[ Edited ]

 

I should be more clear on the problem.... assuming that Math.random() returns a whole number between 0-100 (or your function prints the value of Math.floor(100 * Math.random()):

If I start my app in the simulator and I have a loop printing the values from the random function above I would get:

5, 32, 96, 7 etc....

Now I shut down my application in the simulator... I start up my application again, and the values I get from my loop would again be:

5, 32, 96, 7 etc....

 

I get the same sequence every time I start the application... doesn't matter if I restart the simulator, or reboot my machine. With every run of my application, I always get the same sequence of random numbers.

 

If you don't see the same behavior, I'm wondering if its related to the simulator / VMWare running on my specific machine spec (although I don't think I had this problem with the previous version of the simulator).

 

FLoPMT, what version of VMWare Player are you using? If I remember correctly, I believe there was also an upgrade to VMWare player about the same time that the latest version of the SDK and simulator came out. Mine is version 3.1.4 build-385536.

 

Also, are you building on Windows (7) or Mac?

 

Thanks.

 

Developer
Posts: 160
Registered: ‎03-12-2011
My Device: PlayBook♥
My Carrier: eplus

Re: Playbook Simulator / Webworks bug

I'm using VMWare Fusion for Mac OS X 10.6

----------
Please give free Likes if I helped you out! :smileyhappy:
Retired
Posts: 1,382
Registered: ‎07-02-2009
My Device: BlackBerry Bold 9900
My Carrier: Bell

Re: Playbook Simulator / Webworks bug

>> Where would we go about filing bugs? I don't think I've seen this option anywhere.

 

Please file defects in the BlackBerry Developer Issue Tracker.  

 

There is a category for Tablet OS.

Follow me on Twitter: @n_adam_stanley
-------------------------------------------------------------------------------------------------------------------------
Your app doesn't work? Use BlackBerry remote web inspector to find out why.
Developer
Posts: 25
Registered: ‎03-27-2011
My Device: developer
My Carrier: Free Mobile

Re: Playbook Simulator / Webworks bug

Yes, I have the same issue.
I have two applications for the playbook : a sliding puzzle and a coloring game for kids.
In both of this games, I choose the first picture at random.
And in both game, the first picture is always the same !

I don't really know how it it handled on the real device...

By the way, I though about changing the seed, but you can't do that in Javascript.

Emmanuel / Alocaly