No Java state

Hi everybody,

Im dealing with a really weird bug and can’t find anything by debuggin or googling…

Basicly, i’ve made a function that listens for the back button and goes back one screen:
[lua]-- Key listener
function onKeyEvent( event )
local phase = event.phase
local keyName = event.keyName

print(“1”)

if phase == “up” and keyName == “back” then
print(“2”)
if #breadcrumbs > 1 and androidBackEnabled == true and not modal.lastModal then
print(“3”)
goto(“back”);
elseif currentType == menu_splash then
print(“4”)
if tappedBackTwice then
print(“6”)
os.exit();
else
print(“5”)
toast.new(language.get(“general”, “toast_close_app”), 3000)
tappedBackTwice = true;
timer.performWithDelay(3000, function() tappedBackTwice = false end);
end
end
end
end

local isSimulator = system.getInfo(“environment”) == “simulator”;
function onTilt(event)
if event.isShake then
onKeyEvent({
phase = “up”,
keyName = “back”,
})
end
end

– Add the key callback
Runtime:addEventListener( “key”, onKeyEvent )
if ( isSimulator ) then Runtime:addEventListener( “accelerometer”, onTilt ) end[/lua]

As you can see i’ve added print statements all the way up to where my view manager will receive the ‘back’ command.

The situation is; on the simulator this code runs just fine and even when i call the function goto(‘back’) from a regular on screen button nothing goes wrong.
However, when i press the physical back button on an android device i can see the view starting it’s transition effect, and after about half a second it crashes just like that…

The only output i am getting is:
[text]
I/Corona (24499): 1
I/Corona (24499): 1
I/Corona (24499): 2
I/Corona (24499): 3
I/Corona (24499): Lua Runtime Error: lua_pcall failed with status: 2, error message is: no Java state
[/text]

I’m at a loss here…
Can anyone help me figure out what is happening?
[import]uid: 59229 topic_id: 33861 reply_id: 333861[/import]

Can you post your code for your goto function?

Have you tried wrapping the goto call in a timer.performWithDelay() call, maybe 5-10 ms?

[import]uid: 199310 topic_id: 33861 reply_id: 134607[/import]

Hey Rob,

http://www.pitchblackcat.nl/lab/menu_manager.lua

This will point you to the entire lua file, containing both the back button listener and the goto function.
Sadly, the timer.performWithDelay did not help…

Please be aware that this used to work a couple iterations back, I just don’t really remember when and i can’t remember tinkering with these functions either…

I’ve tried this both on the last stable build and the current daily build:
CoronaSDK-2012.971
CoronaSDK-2012.978 [import]uid: 59229 topic_id: 33861 reply_id: 134614[/import]

The “no Java state” error is something we haven’t seen before. Are you using the Debug keystore key when you do your Android builds? The debug builds should display the filename and line number where the error occurs. I didn’t see that in your logcat output so you may be using your own key.

You will need to track down the problem by adding more print statements to your code to find out where it’s going before it gets the error.

By the way, you shouldn’t be using os.exit in your code. That causes the program to end abruptly. On Android, you should use native.requestExit() instead. [import]uid: 7559 topic_id: 33861 reply_id: 134717[/import]

Here is the logcat output when compiled with the debug.keystore:
ps. I’ve added an arrow behind every line that explicitly comes from my application

[text]
12-12 10:40:43.710: W/IInputConnectionWrapper(2119): showStatusIcon on inactive InputConnection 12-12 10:40:43.775: D/dalvikvm(2119): GC_CONCURRENT freed 3241K, 42% free 12603K/21575K, paused 15ms+3ms, total 49ms 12-12 10:40:43.775: V/SoundPoolThread(2119): Got message m=1, mData=0 12-12 10:40:43.775: V/SoundPoolThread(2119): goodbye 12-12 10:40:43.775: V/SoundPoolThread(2119): return from quit 12-12 10:40:43.775: V/AudioPolicyManagerBase(1908): getNewDevice() selected device 0
12-12 10:40:43.775: V/SoundPoolThread(2119): return from quit 12-12 10:40:43.780: I/Corona(2119): Lua Runtime Error: lua_pcall failed with status: 2, error message is: no Java state 12-12 10:40:43.790: D/dalvikvm(2607): GC_CONCURRENT freed 385K, 9% free 12138K/13319K, paused 2ms+2ms, total 27ms
12-12 10:40:43.810: I/OpenAL_SLES(2119): opensles_stop_playback device=0x5f0c8008 12-12 10:40:43.810: I/OpenAL_SLES(2119): opensles_close_playback pDevice=0x5f0c8008 12-12 10:40:43.815: V/AudioPolicyManagerBase(1908): releaseOutput() 2
12-12 10:40:43.825: D/KeyguardViewMediator(2267): setHidden false
12-12 10:40:43.825: D/KeyguardViewMediator(2267): setHidden false
12-12 10:40:43.845: D/KeyguardViewMediator(2267): setHidden false
12-12 10:40:43.845: D/KeyguardViewMediator(2267): setHidden false
12-12 10:40:44.365: D/lights(2267): button : 2 +
12-12 10:40:44.365: D/lights(2267): button : 2 -
[/text]

Still no such thing as a line number, so i’ll try a print after every line now… [import]uid: 59229 topic_id: 33861 reply_id: 134786[/import]

Long story short:
It reaches the end of the onKeyDown function and/or the goto function, depending on which side of the if statement gets triggered…

I suppose i’ll dump some more logcat output here:
[text]
12-12 10:56:04.810: D/dalvikvm(9798): GC_CONCURRENT freed 1457K, 42% free 12639K/21575K, paused 17ms+13ms, total 42ms
12-12 10:56:04.835: I/Corona(9798): k
12-12 10:56:04.835: I/Corona(9798): l
12-12 10:56:04.870: D/SensorManager(9798): unregisterListener:: Listener= android.view.OrientationEventListener$SensorEventListenerImpl@41d017d0
12-12 10:56:04.870: D/Sensors(9798): Remain listener = Sending … normal delay 200ms
12-12 10:56:04.870: I/Sensors(9798): sendDelay — 200000000
12-12 10:56:04.870: D/SensorManager(9798): JNI - sendDelay
12-12 10:56:04.870: I/SensorManager(9798): Set normal delay = true
12-12 10:56:04.880: D/FlurryAgent(9798): Ending session
12-12 10:56:05.135: W/SurfaceView(9798): CHECK surface infomation creating=false formatChanged=false sizeChanged=false visible=false visibleChanged=true surfaceChanged=true realSizeChanged=false redrawNeeded=false left=false top=false
12-12 10:56:05.805: W/IInputConnectionWrapper(9798): showStatusIcon on inactive InputConnection
12-12 10:56:05.840: V/SoundPoolThread(9798): Got message m=1, mData=0
12-12 10:56:05.840: V/SoundPoolThread(9798): goodbye
12-12 10:56:05.845: V/SoundPoolThread(9798): return from quit
12-12 10:56:05.845: V/SoundPoolThread(9798): return from quit
12-12 10:56:05.845: I/Corona(9798): Lua Runtime Error: lua_pcall failed with status: 2, error message is: no Java state
12-12 10:56:05.870: I/OpenAL_SLES(9798): opensles_stop_playback device=0x5f088008
12-12 10:56:05.870: I/OpenAL_SLES(9798): opensles_close_playback pDevice=0x5f088008
12-12 10:56:14.895: D/FlurryAgent(9798): Sending report to: http://data.flurry.com/aar.do
12-12 10:56:15.275: D/FlurryAgent(9798): Report successful
12-12 10:56:24.045: D/dalvikvm(9798): GC_CONCURRENT freed 467K, 42% free 12602K/21575K, paused 5ms+3ms, total 40ms
[/text]

Im pretty much out of ideas of how to debug this… [import]uid: 59229 topic_id: 33861 reply_id: 134787[/import]

And then it hit me like a speeding train -__-;;
I wasn’t capturing the back button!

I should’ve added
[lua]return true;[/lua]
to the onKeyEvent!

Thanks for trying to help me out, Rob and Tom!
ps. If you want, I can provide a small test project to replicate this. [import]uid: 59229 topic_id: 33861 reply_id: 134789[/import]

I’m glad you found the problem and it’s strange about the lack of file name and line number for the Lua error.

We would be interested in seeing a small test case that shows the error so we can track down where it’s coming from and hopefully improve the error message. Just attach it to a bug report and mentioned/link to this thread.

Thanks.
Tom [import]uid: 7559 topic_id: 33861 reply_id: 134837[/import]

Can you post your code for your goto function?

Have you tried wrapping the goto call in a timer.performWithDelay() call, maybe 5-10 ms?

[import]uid: 199310 topic_id: 33861 reply_id: 134607[/import]

Hey Rob,

http://www.pitchblackcat.nl/lab/menu_manager.lua

This will point you to the entire lua file, containing both the back button listener and the goto function.
Sadly, the timer.performWithDelay did not help…

Please be aware that this used to work a couple iterations back, I just don’t really remember when and i can’t remember tinkering with these functions either…

I’ve tried this both on the last stable build and the current daily build:
CoronaSDK-2012.971
CoronaSDK-2012.978 [import]uid: 59229 topic_id: 33861 reply_id: 134614[/import]

The “no Java state” error is something we haven’t seen before. Are you using the Debug keystore key when you do your Android builds? The debug builds should display the filename and line number where the error occurs. I didn’t see that in your logcat output so you may be using your own key.

You will need to track down the problem by adding more print statements to your code to find out where it’s going before it gets the error.

By the way, you shouldn’t be using os.exit in your code. That causes the program to end abruptly. On Android, you should use native.requestExit() instead. [import]uid: 7559 topic_id: 33861 reply_id: 134717[/import]

Here is the logcat output when compiled with the debug.keystore:
ps. I’ve added an arrow behind every line that explicitly comes from my application

[text]
12-12 10:40:43.710: W/IInputConnectionWrapper(2119): showStatusIcon on inactive InputConnection 12-12 10:40:43.775: D/dalvikvm(2119): GC_CONCURRENT freed 3241K, 42% free 12603K/21575K, paused 15ms+3ms, total 49ms 12-12 10:40:43.775: V/SoundPoolThread(2119): Got message m=1, mData=0 12-12 10:40:43.775: V/SoundPoolThread(2119): goodbye 12-12 10:40:43.775: V/SoundPoolThread(2119): return from quit 12-12 10:40:43.775: V/AudioPolicyManagerBase(1908): getNewDevice() selected device 0
12-12 10:40:43.775: V/SoundPoolThread(2119): return from quit 12-12 10:40:43.780: I/Corona(2119): Lua Runtime Error: lua_pcall failed with status: 2, error message is: no Java state 12-12 10:40:43.790: D/dalvikvm(2607): GC_CONCURRENT freed 385K, 9% free 12138K/13319K, paused 2ms+2ms, total 27ms
12-12 10:40:43.810: I/OpenAL_SLES(2119): opensles_stop_playback device=0x5f0c8008 12-12 10:40:43.810: I/OpenAL_SLES(2119): opensles_close_playback pDevice=0x5f0c8008 12-12 10:40:43.815: V/AudioPolicyManagerBase(1908): releaseOutput() 2
12-12 10:40:43.825: D/KeyguardViewMediator(2267): setHidden false
12-12 10:40:43.825: D/KeyguardViewMediator(2267): setHidden false
12-12 10:40:43.845: D/KeyguardViewMediator(2267): setHidden false
12-12 10:40:43.845: D/KeyguardViewMediator(2267): setHidden false
12-12 10:40:44.365: D/lights(2267): button : 2 +
12-12 10:40:44.365: D/lights(2267): button : 2 -
[/text]

Still no such thing as a line number, so i’ll try a print after every line now… [import]uid: 59229 topic_id: 33861 reply_id: 134786[/import]

Long story short:
It reaches the end of the onKeyDown function and/or the goto function, depending on which side of the if statement gets triggered…

I suppose i’ll dump some more logcat output here:
[text]
12-12 10:56:04.810: D/dalvikvm(9798): GC_CONCURRENT freed 1457K, 42% free 12639K/21575K, paused 17ms+13ms, total 42ms
12-12 10:56:04.835: I/Corona(9798): k
12-12 10:56:04.835: I/Corona(9798): l
12-12 10:56:04.870: D/SensorManager(9798): unregisterListener:: Listener= android.view.OrientationEventListener$SensorEventListenerImpl@41d017d0
12-12 10:56:04.870: D/Sensors(9798): Remain listener = Sending … normal delay 200ms
12-12 10:56:04.870: I/Sensors(9798): sendDelay — 200000000
12-12 10:56:04.870: D/SensorManager(9798): JNI - sendDelay
12-12 10:56:04.870: I/SensorManager(9798): Set normal delay = true
12-12 10:56:04.880: D/FlurryAgent(9798): Ending session
12-12 10:56:05.135: W/SurfaceView(9798): CHECK surface infomation creating=false formatChanged=false sizeChanged=false visible=false visibleChanged=true surfaceChanged=true realSizeChanged=false redrawNeeded=false left=false top=false
12-12 10:56:05.805: W/IInputConnectionWrapper(9798): showStatusIcon on inactive InputConnection
12-12 10:56:05.840: V/SoundPoolThread(9798): Got message m=1, mData=0
12-12 10:56:05.840: V/SoundPoolThread(9798): goodbye
12-12 10:56:05.845: V/SoundPoolThread(9798): return from quit
12-12 10:56:05.845: V/SoundPoolThread(9798): return from quit
12-12 10:56:05.845: I/Corona(9798): Lua Runtime Error: lua_pcall failed with status: 2, error message is: no Java state
12-12 10:56:05.870: I/OpenAL_SLES(9798): opensles_stop_playback device=0x5f088008
12-12 10:56:05.870: I/OpenAL_SLES(9798): opensles_close_playback pDevice=0x5f088008
12-12 10:56:14.895: D/FlurryAgent(9798): Sending report to: http://data.flurry.com/aar.do
12-12 10:56:15.275: D/FlurryAgent(9798): Report successful
12-12 10:56:24.045: D/dalvikvm(9798): GC_CONCURRENT freed 467K, 42% free 12602K/21575K, paused 5ms+3ms, total 40ms
[/text]

Im pretty much out of ideas of how to debug this… [import]uid: 59229 topic_id: 33861 reply_id: 134787[/import]

And then it hit me like a speeding train -__-;;
I wasn’t capturing the back button!

I should’ve added
[lua]return true;[/lua]
to the onKeyEvent!

Thanks for trying to help me out, Rob and Tom!
ps. If you want, I can provide a small test project to replicate this. [import]uid: 59229 topic_id: 33861 reply_id: 134789[/import]

I’m glad you found the problem and it’s strange about the lack of file name and line number for the Lua error.

We would be interested in seeing a small test case that shows the error so we can track down where it’s coming from and hopefully improve the error message. Just attach it to a bug report and mentioned/link to this thread.

Thanks.
Tom [import]uid: 7559 topic_id: 33861 reply_id: 134837[/import]

Hey Tom,

Here’s a small mini project that’ll cause this error to pop up.
I suppose it’s due to a timer.performWithDelay function that extents beyond the apps actual life.

http://pitchblackcat.nl/lab/corona/no-java-state/

Hope you can make a human-understandable error message out of this, because debugging it was hell.

Thanks for the help,
~PitchBlackCat [import]uid: 59229 topic_id: 33861 reply_id: 135411[/import]

Hey Tom,

Here’s a small mini project that’ll cause this error to pop up.
I suppose it’s due to a timer.performWithDelay function that extents beyond the apps actual life.

http://pitchblackcat.nl/lab/corona/no-java-state/

Hope you can make a human-understandable error message out of this, because debugging it was hell.

Thanks for the help,
~PitchBlackCat [import]uid: 59229 topic_id: 33861 reply_id: 135411[/import]