My app is logging when application suspend and resume events occur. On an iPhone 6 I am seeing rapid (~100ms interval) application resume and suspend events.
I was wondering if anyone else had seen this is their code?
My app is logging when application suspend and resume events occur. On an iPhone 6 I am seeing rapid (~100ms interval) application resume and suspend events.
I was wondering if anyone else had seen this is their code?
Can you post the addEventListener line and the listener function code?
Sure, it’s a little complex, but that may be the issue:
[lua]
function logSessionStart(type)
database.log(“session”,{
time=os.date("%T"),
date=os.date("%F"),
appMillis=system.getTimer(),
userid=user.getID(),
type=type
})
end
local sessionlogger=require “sessionlogger”
Runtime:addEventListener(“system”, function(event)
if not user.getID() then
# true on first launch when the user has not created an account
return
end
if event.type==“applicationResume” or event.type==“applicationStart” then
# load from JSON file
local prev=sessionlogger.getPreviousSession()
if prev and next(prev) then
database.log(“session”,prev)
sessionlogger.clearHistory() # writes a blank table to JSON file
end
logSessionStart(event.type)
end
if event.type==“applicationSuspend” or event.type==“applicationExit” then
sessionlogger.logSessionEnd(event.type)
end
end)
[/lua]
Have you tried this code with a recent, but not current, daily build? Do you know when the excessive events started?
The issue’s been there from the start: as soon as I started logging the start and end of sessions. I’m wondering whether it’s something with my code
I think there’s a bug in Corona. I built a little app to test the problem in isolation:
[lua]
local systemEvents={}
local label=display.newText({
x=20,
y=20,
text="-",
width=display.contentWidth-40
})
label.anchorX=0
label.anchorY=0
Runtime:addEventListener(“system”,function(event)
systemEvents[#systemEvents+1]=event.type…" - "…system.getTimer()
label.text=table.concat(systemEvents,"\n")
end)
[/lua]
When I try the following code on iPhone SE I always see a very quick succession of applicationStart, applicationSuspended and then applicationResume - it looks like they all happen in the same frame. I’ve filed a bug report (though I have not received the usual confirmation e-mail)
Can you post the addEventListener line and the listener function code?
Sure, it’s a little complex, but that may be the issue:
[lua]
function logSessionStart(type)
database.log(“session”,{
time=os.date("%T"),
date=os.date("%F"),
appMillis=system.getTimer(),
userid=user.getID(),
type=type
})
end
local sessionlogger=require “sessionlogger”
Runtime:addEventListener(“system”, function(event)
if not user.getID() then
# true on first launch when the user has not created an account
return
end
if event.type==“applicationResume” or event.type==“applicationStart” then
# load from JSON file
local prev=sessionlogger.getPreviousSession()
if prev and next(prev) then
database.log(“session”,prev)
sessionlogger.clearHistory() # writes a blank table to JSON file
end
logSessionStart(event.type)
end
if event.type==“applicationSuspend” or event.type==“applicationExit” then
sessionlogger.logSessionEnd(event.type)
end
end)
[/lua]
Have you tried this code with a recent, but not current, daily build? Do you know when the excessive events started?
The issue’s been there from the start: as soon as I started logging the start and end of sessions. I’m wondering whether it’s something with my code
I think there’s a bug in Corona. I built a little app to test the problem in isolation:
[lua]
local systemEvents={}
local label=display.newText({
x=20,
y=20,
text="-",
width=display.contentWidth-40
})
label.anchorX=0
label.anchorY=0
Runtime:addEventListener(“system”,function(event)
systemEvents[#systemEvents+1]=event.type…" - "…system.getTimer()
label.text=table.concat(systemEvents,"\n")
end)
[/lua]
When I try the following code on iPhone SE I always see a very quick succession of applicationStart, applicationSuspended and then applicationResume - it looks like they all happen in the same frame. I’ve filed a bug report (though I have not received the usual confirmation e-mail)