60FPS App receives only 30 touches per second.

Hello,

I have figgured out a bug.

I have also already broken it down as far as it was possible for me.

(I have already reported it as a bug but did not receive an email yet with a case ID)

If somebody has encoutered similar issues or knows a workaround I’d love to hear from you :wink:

Here it goes:

I have an app running on 60 FPS.

I also expect (at least) 60 touch events per second on a touch event listener.

Here is the project sample that works perfectly fine:

config.lua

application = {     content = {         width = 1080,         height = 1920,         scale = "letterBox",         fps = 60,         xAlign = "center",         yAlign = "center",     }, }

main.lua

local widget = require( "widget" ) local spinningObj = display.newRect( 100, 100, 100, 100 ) function globalFPSTimerDummy(e)    --spinningObj.rotation = spinningObj.rotation + 3    --if spinningObj.rotation \> 360 then    --    spinningObj.rotation = spinningObj.rotation - 360    --end end Runtime:addEventListener( "enterFrame", globalFPSTimerDummy ) local ctr = 0 local function printThis(e) print("hey there ", ctr) ctr = ctr + 1 end local levelSelectionScrollView levelSelectionScrollView = widget.newScrollView {    width = 1080,    height = 1920,    scrollWidth = 1080,    scrollHeight = 1920,    hideBackground = true,    listener = printThis, } local someRect = display.newRect( 500, 500, 100, 100 ) someRect.strokeWidth = 8 someRect:setFillColor( 0.0 ) levelSelectionScrollView:insert(someRect)

This project sample (consiting only of the main and the config file) shows the print “hey there some#” 60 times per second.

All I do in the program is swiping on the screen up and down.

(You can see the rect moving smoothly)

So now it get weird:

I uncomment the lines:

    --spinningObj.rotation = spinningObj.rotation + 3     --if spinningObj.rotation \> 360 then     --    spinningObj.rotation = spinningObj.rotation - 360     --end

recompile and reinstall … and now

The print “hey there some#” occures only 30 times per second.

While scolling the scrollView “someRect” you can see the difference it makes having 30 fps.

(The rect is now not as smooth as it used to be.

However!!! - the scroll view transition that scrolls the rect back in place is smooth)

Please Note:

Sometimes this error does not occur immediately.

In this case susspending the app by pressing the home button and reopening it like 3 seconds later makes the error occur.

In our main project we did not observe this error with android.

To test this I have used

Corona Version 3012

Compiled on a MAC.

Device: IPAD Air 2 and IPhone 6S

Thank you for the good work really appreciate it :slight_smile:

Your bug report is not in the system. Please try by emailing support@coronalabs.com with  your project attached and a good description of the problem.

Thanks

Rob

I have sent the email.  :slight_smile:

Case # 7500380

Thanks!

Rob

Hi there!

Are there any updates on the progress of solving this case?

this bug is really bothering us, because our game is almost finished and we want to release soon but with this bug the gameplay feels really juddery on iOS.

We have a touch based Retro Shoot 'Em Up so it’s really important the the touch is reacting fast to make it feel responsive.

Thank you for your support!

Patrick

We are still investigating it. 

Rob

Hey guys.

I’m sorry to bring dire news, but it seems like iOS issue. I can confirm that it happens. I also tried to make bare-bones iOS app, and it happens there too, without Corona.

By the way. FPS is not attached to touch screen event rate. You will get same event rate regardless of your set FPS. iOS does not provide guarantee for touch screen event rate. Observation of myself, and other people online I encountered investigating the issue says that it rarely goes below 30. Note, that setting fps=30, will not bring down touch event rate. You would get same amount of events reported.

Good news, is that it doesn’t affect actual game FPS. It is generally not a good idea to rely on touch screen resolution/responsiveness too much. You still get 60 frames rendered on screen, so you can interpolate between frames, but you’ll have to do some kind of interpolation for input.

Simpler code to observe the issue:

[lua]

local spinningObj = display.newRect( 100, 100, 100, 100 )

local trans = false

local touches = 0

local function toggleTrans(  )

    if trans then

        transition.cancel( trans )

        trans = false

    else

        spinningObj.rotation = 0

        trans =  transition.to( spinningObj, {rotation=360, iterations=0, time=12000} )

    end

end

spinningObj:addEventListener( “tap”, toggleTrans )

toggleTrans()

Runtime:addEventListener(‘touch’, function( e )    

    if e.phase == “moved” then 

       touches = touches + 1

    end

end )

local displayText = display.newText("…", display.contentCenterX, display.contentCenterY, nil, 100 )

timer.performWithDelay( 1000, function( )

    – print(touches)

    displayText.text = tostring( touches )

    touches = 0

end, 0 )

[/lua]

Also, here’s a link people hitting same issue with Unity http://stackoverflow.com/questions/21242212/touchesmoved-called-at-irregular-intervals

Oh, well I see. Bummer :wacko:

Okay… I like the idea of an interpolation. Basically I know what an interpolation would look like. If I knew it was needed.

But I’m stuck by detecting that the device runs on 30 touches per second.

Every time the user moves his finger a new event is triggered.

But if the user moves his hand slowly I might only get <= 30 touches per second anyway.

So I’m thinking about the rule 3 touches per 1/10th of a second triggers an interpolation for the next frame.

But even in this case a short fast swipe might look weird.

The complexity for such an interpolation that would make things actually look smooth on (restricted) 30 touches per second and possible 60 touches per second seems pretty high to me.

Does someone have an Idea on detecting a needed interpolation?

So far I did not come up with a proper solution for an interpolation.

However, in the mean time the solution for this issue was answered in the thread vlads posted.

http://stackoverflow.com/questions/21242212/touchesmoved-called-at-irregular-intervals

Apple Quote:

“As long as you don’t cause any display updates the screen stays in low power and therefore 30hz mode, which in turn also keeps the event input stream down at 30 hz. A workaround is to actually cause a display update on each received move, even if it is just a one pixel move of a view if input is needed while no explicit screen update will be triggered.”

I have added a new Bug Ticket for this issue.

Your bug report is not in the system. Please try by emailing support@coronalabs.com with  your project attached and a good description of the problem.

Thanks

Rob

I have sent the email.  :slight_smile:

Case # 7500380

Thanks!

Rob

Hi there!

Are there any updates on the progress of solving this case?

this bug is really bothering us, because our game is almost finished and we want to release soon but with this bug the gameplay feels really juddery on iOS.

We have a touch based Retro Shoot 'Em Up so it’s really important the the touch is reacting fast to make it feel responsive.

Thank you for your support!

Patrick

We are still investigating it. 

Rob

Hey guys.

I’m sorry to bring dire news, but it seems like iOS issue. I can confirm that it happens. I also tried to make bare-bones iOS app, and it happens there too, without Corona.

By the way. FPS is not attached to touch screen event rate. You will get same event rate regardless of your set FPS. iOS does not provide guarantee for touch screen event rate. Observation of myself, and other people online I encountered investigating the issue says that it rarely goes below 30. Note, that setting fps=30, will not bring down touch event rate. You would get same amount of events reported.

Good news, is that it doesn’t affect actual game FPS. It is generally not a good idea to rely on touch screen resolution/responsiveness too much. You still get 60 frames rendered on screen, so you can interpolate between frames, but you’ll have to do some kind of interpolation for input.

Simpler code to observe the issue:

[lua]

local spinningObj = display.newRect( 100, 100, 100, 100 )

local trans = false

local touches = 0

local function toggleTrans(  )

    if trans then

        transition.cancel( trans )

        trans = false

    else

        spinningObj.rotation = 0

        trans =  transition.to( spinningObj, {rotation=360, iterations=0, time=12000} )

    end

end

spinningObj:addEventListener( “tap”, toggleTrans )

toggleTrans()

Runtime:addEventListener(‘touch’, function( e )    

    if e.phase == “moved” then 

       touches = touches + 1

    end

end )

local displayText = display.newText("…", display.contentCenterX, display.contentCenterY, nil, 100 )

timer.performWithDelay( 1000, function( )

    – print(touches)

    displayText.text = tostring( touches )

    touches = 0

end, 0 )

[/lua]

Also, here’s a link people hitting same issue with Unity http://stackoverflow.com/questions/21242212/touchesmoved-called-at-irregular-intervals

Oh, well I see. Bummer :wacko:

Okay… I like the idea of an interpolation. Basically I know what an interpolation would look like. If I knew it was needed.

But I’m stuck by detecting that the device runs on 30 touches per second.

Every time the user moves his finger a new event is triggered.

But if the user moves his hand slowly I might only get <= 30 touches per second anyway.

So I’m thinking about the rule 3 touches per 1/10th of a second triggers an interpolation for the next frame.

But even in this case a short fast swipe might look weird.

The complexity for such an interpolation that would make things actually look smooth on (restricted) 30 touches per second and possible 60 touches per second seems pretty high to me.

Does someone have an Idea on detecting a needed interpolation?

So far I did not come up with a proper solution for an interpolation.

However, in the mean time the solution for this issue was answered in the thread vlads posted.

http://stackoverflow.com/questions/21242212/touchesmoved-called-at-irregular-intervals

Apple Quote:

“As long as you don’t cause any display updates the screen stays in low power and therefore 30hz mode, which in turn also keeps the event input stream down at 30 hz. A workaround is to actually cause a display update on each received move, even if it is just a one pixel move of a view if input is needed while no explicit screen update will be triggered.”

I have added a new Bug Ticket for this issue.