cr.createRuntime("c2canvas") loop

Bugs will be moved here once resolved.

Post » Tue Feb 21, 2012 8:07 pm

I was wondering lately why every time i run my mobile (phonegap, appmobi) app it runs slower and slower every time i did it. So i googled a little, and knowing that exiting an app doesn't really close it, app just goes to background, I think, that every time it is brought back to top there is another runtime created by cr.createRuntime("c2canvas"); as the listener "deviceready" gets a hit :) I think there should be some kind of check if the runtime is already created, and if it is, don't create another. Would be grateful for some kind of workaround until text build :) maybe some kind of
[code]
if (!runtime) {cr.createRuntime("c2canvas");}
[/code] or something, in the index.html
cheers!
B
81
S
50
G
10
Posts: 555
Reputation: 13,009

Post » Wed Feb 22, 2012 12:35 am

Really? Are you sure this is the problem? Which export format are you using? It uses different events to create the runtime depending on the platform. Still, I'll add once-only checks to all export formats just in case.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,478

Post » Wed Feb 22, 2012 9:45 am

i think a simple pseudocode:
[code]var created = false;
ondeviceready(function(){
if (!created) {
cr.createRuntime("c2canvas");
created = true;
}
});[/code]
would work, I will check it today if this work.
what am I sure of now is that every time i bring app to front after putting it to sleep, it runs slower and slower. appmobi AND phonegap export.
cheers
B
81
S
50
G
10
Posts: 555
Reputation: 13,009

Post » Wed Feb 22, 2012 12:09 pm

ok, i don't seem to be able to reproduce it with phonegap export, but in appmobi export, how to reproduce:

1) create a 500x500 jpeg background with some image, scale it to 100x100
2) create a 500x500 sprite with some opacity, scale it to 100x100
3) add a rotating behavior to the sprite with some medium speed of your choice
4) export through appmobi and install
5) run on device
6) double tap back button to exit (put app in background - you can see in application manager that the app is still running in background)
7) run app again
8) repeat steps 6 -> 7 to see fps degradation of the rotationg sprite
B
81
S
50
G
10
Posts: 555
Reputation: 13,009

Post » Thu Feb 23, 2012 2:05 am

I think it would be very odd if the "page ready" event fired more than once, but regardless I've put a check in the next build which will prevent creating a second runtime if one already exists. Perhaps appMobi is just starting multiple apps and you need to close everything?
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,478


Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 2 guests