Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Timers issue in the new CoronaCards WP8 build (2014.2369)
Started by whammy Jul 17 2014 01:58 PM

13 replies to this topic
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

whammy

[GLOBAL: userInfoPane.html]
whammy
  • Contributor

  • 202 posts
  • Corona SDK

Joshua,

 

After updating to the new CoronaCards build (2014.2369) I encounter a new bug that probably has something to do with timers accuracy.

 

I have one moment in my game where I show a 'save me' popup - if the player clicks it, he/she can continue the game after paying some coins. If not - the score screen shows up. This was the moment (showing the score screen) when I noticed that the transitions weren't complete in the previous CoronaCards build I tested (2014.2357) - you remember the issue I was telling you about. But in that previous build everything worked fine after settling the scene. Button event listeners worked fine and timers executed on that score screen. But now in the updated build (2369) after showing score screen something is messed up - timers seem to be paused (my blinking button doesn't blink), and I'm not able to restart the game.

 

To confirm: I uninstalled 2369 build and installed again 2357 build - everything worked fine again (the same code also works perfectly fine on iOS: with no errors in XCode console). After updating to 2369 - I'm getting a bug in that score screen. I don't have any errors in visual studio console neither, but I don't get any Corona errors in Visual studio at all. I can read only print() lines I call. So I can't say what's particularly causing that bug, but I'm certainly sure it has something to do with timers change that you were adjusting for the 2369 build.

 

To sum up - timers from 2357 build worked fine, although transitions weren't always complete. Timers from 2369 build are causing a bug.



[TOPIC: post.html]
#2

whammy

[GLOBAL: userInfoPane.html]
whammy
  • Contributor

  • 202 posts
  • Corona SDK

One thing that might help your investigation: I'm getting this bug after scene:overlayEnded event. When I call the same function without showing an overlay scene - timers work fine.



[TOPIC: post.html]
#3

Joshua Quick

[GLOBAL: userInfoPane.html]
Joshua Quick
  • Moderator

  • 3,397 posts
  • Corona Staff

I'm not sure I understand what the issue is.

 

Are you saying the app is hung?

Like it stops rendering and tapping on the screen does nothing?



[TOPIC: post.html]
#4

Joshua Quick

[GLOBAL: userInfoPane.html]
Joshua Quick
  • Moderator

  • 3,397 posts
  • Corona Staff

I also tried testing some apps with multiple timers and another app with composer which transitions between scenes (using *.ccscene files).  I didn't see any issues.  But I'm still not clear as to what issue you are seeing.

 

Also, would you mind testing your app with that same build # on iOS or Android?

This is to check if this is an issue in our core code (ie: on all platforms).

I ask because our WP8 builds will include all of the core code changes in our daily builds.



[TOPIC: post.html]
#5

whammy

[GLOBAL: userInfoPane.html]
whammy
  • Contributor

  • 202 posts
  • Corona SDK

Sorry for not being clear. The app is partially hung. I can hit the button but it doesn't dispatch all the functions. This moment in my app relies on the timers and my guess is that some method is diapatched earlier/later than it should and this is causing an error.

Is there a way to display Corona errors in the Visual Studio output? The guide you provided let me read print lines only but not lua errors. I can't say what's really going on because on iOS and Corona simulator it works fine (with the daily build as well).

[TOPIC: post.html]
#6

whammy

[GLOBAL: userInfoPane.html]
whammy
  • Contributor

  • 202 posts
  • Corona SDK

I'm using storyboard if that makes a difference.

 

I added unhandledError runtime listener but it didn't reproduce any error to the output of visual studio. So I made a compile error on purpose to check if that listener works - it does work and it prints errors properly, so I don't know why in the moment when my app partially hangs, there's no error in the output. It's really strange.

Anyway - the same code doesn't hang on iOS nor with the 2357 build on WP8.



[TOPIC: post.html]
#7

whammy

[GLOBAL: userInfoPane.html]
whammy
  • Contributor

  • 202 posts
  • Corona SDK

my PSEUDO code logic looks like this:

didShowOverlayScene = false

button = newButton()

timer.performWithDelay(1,function(e)
   timeAfterButtonDisplay = e.count
   if not didShowOverlayScene and e.count == 1000 then
       showScore()
   end
end,1000)

function button:tap()
   if timeAfterButtonDisplay < 1000 then
      didShowOverlayScene = true
      showOverlayScene() 
   else
      restartGame()
   end  
end

button:addEventListener("tap", button)

function scene:overlayEnded(e)
     showScore()
end

scene:addEventListener( "overlayEnded" )

So when I do nothing and just wait for the score to appear - then I can restart game by hitting the button after 1s with no issues. The problem appears when I hit the button before 1s to show the overlay scene. So when I close the overlay scene (thus - I dispatch the same showScore method) then I'm not able to restart the game. Actually the game restarts, but the score screen doesn't disappear and there's a mess happening on the screen.

I'm 100% sure it's not my code issue since it was working fine all the time and it still does on the previous CoronaCards build and on iOS.



[TOPIC: post.html]
#8

whammy

[GLOBAL: userInfoPane.html]
whammy
  • Contributor

  • 202 posts
  • Corona SDK

Joshua,

I think I got to the problem - it seems that after overlayEnded event occurs no transitions are deployed from within button listeners. I tired to add this simple code to my button instead of my regular restartGame() function:

function button:tap()
	print("TAP TAP")
	local circleTrans1
        local circleTrans2

	local function makeCircle2()
		print("circle2 BEGIN")
		local circle2 = display.newCircle( _W*0.5, _H*0.5+30, 30 )
		circle2.alpha = 0

		local function nilOut()
			print("NIL BEGIN")
			transition.cancel(circleTrans1)
			transition.cancel(circleTrans2)
			circleTrans1 = nil
			circleTrans2 = nil
		end
		
		circleTrans2 = transition.to(circle2, {
			time = 500,
			alpha = 1,
			onComplete = nilOut
			})
	end

	local circle = display.newCircle( _W*0.5, _H*0.5, 30 )
	circle.alpha = 0
	
	circleTrans1 = transition.to(circle, {
		time = 500,
		alpha = 1,
		onComplete = makeCircle2
		})
end

So when I click the button after overlayEnded event occurred - I'm getting "TAP TAP" printed in the output but no visible circles, and no more print outputs. When I change circle.alpha = 1 and circle2.alpha = 1, then I'm getting "TAP TAP" output and one visible circle. 

 

That means, that circleTrans1 transition isn't deployed at all after overlayEnded event.

 

I tried to put the same code inside the scene:overlayEnded function and then the transition worked fine.

They are not deployed when they are triggered from inside button listeners.

 

Does it make any sense?



[TOPIC: post.html]
#9

whammy

[GLOBAL: userInfoPane.html]
whammy
  • Contributor

  • 202 posts
  • Corona SDK

No it's not that. I've made a simple app to test it out and the transitions alone work fine after overlayEnded event... Have no idea what's going on here.



[TOPIC: post.html]
#10

whammy

[GLOBAL: userInfoPane.html]
whammy
  • Contributor

  • 202 posts
  • Corona SDK

OK, so now I removed two transitions from my code and the other transitions work fine. :huh:

I don't know why these two purely visual elements were causing a bug in the latest build but I can live without them.

 

We delete this thread if you want.



[TOPIC: post.html]
#11

Joshua Quick

[GLOBAL: userInfoPane.html]
Joshua Quick
  • Moderator

  • 3,397 posts
  • Corona Staff

I had a quick look at Corona's storyboard library and I can see that it contains some print() function.  I'm wondering if those are the cause of the temporary hanging/blocking since each print() function blocks the app for about 3-4 milliseconds (they're expensive on WP8).

 

Have you tried running your app without the Visual Studio debugger?

That is, after you deploy your app to the WP8 device, stop the debugger, and then run the app yourself manually from the device.  Does it stop blocking then?



[TOPIC: post.html]
#12

whammy

[GLOBAL: userInfoPane.html]
whammy
  • Contributor

  • 202 posts
  • Corona SDK

Yes, I tried it but it didn't make any change. I noticed that I get a slightly better performance when I stop debugging, but unfortunately not this time. It might be the storyboard, still I'm wondering why it's been working with the previous build and now it doesn't. 

 

Anyways - I don't mind removing those 2 additional transitions so I'm happy that I got it to work.



[TOPIC: post.html]
#13

whammy

[GLOBAL: userInfoPane.html]
whammy
  • Contributor

  • 202 posts
  • Corona SDK

Oh, actually I made a quick test and tried to load the overlay as a display.newGroup requiring a regular module, not a storyboard scene. The results were exact the same, so I guess the bug is somewhere else, not in storyboard api.



[TOPIC: post.html]
#14

Joshua Quick

[GLOBAL: userInfoPane.html]
Joshua Quick
  • Moderator

  • 3,397 posts
  • Corona Staff

Well, let's keep this thread open, because I do eventually want to know what exactly is causing this issue.

 

I have a hard time believing it's a timer issue though.  Timers will either elapse on time or late... and never early now.  The only issue you might have with them is if you have something blocking the main UI thread.  You see, your physics based system is framerate driven by default, but timers are based on the device's clock (system ticks really).  What I mean by this is if you block the main UI thread for a minute, then you'll find that your physics system will step by a small duration, but all of your timers may elapse all at once.  I hope what I'm saying makes sense.  So, I'm wondering if something is blocking the main UI thread in your app (which is what we need to track down), which is why your timers seem to be going off early (but by your device's clock, they're actually late).




[topic_controls]
[/topic_controls]