app crash when using MOAIKeyboardAndroid #650

Closed
ggsonic opened this Issue Feb 25, 2013 · 3 comments

2 participants

@ggsonic

I am trying to build my "editbox" component, getting input text from MOAIKeyBoardAndroid,and set it to a MOAITextBox,i seems to work fine,but app always crash when you type into several words. I made several experiments,and it seems that if you simply add a view layer in moai's android/app-keyboard sample, the app crash case can be reproduced.

My Code:
MOAISim.openWindow ( "test", 320, 480)
viewport = MOAIViewport.new ()
viewport:setSize ( 320, 480)
viewport:setScale ( 320, -480)
layer = MOAILayer2D.new ()
layer:setViewport ( viewport )
MOAISim.pushRenderPass ( layer )

charcodes = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 .,:;!?()&/-'
text = "asdfba"
font = MOAIFont.new ()
font:load ( 'fonts/dwarves.TTF' )
font:preloadGlyphs ( charcodes, 16 )

function newStyle ( font, size )
local style = MOAITextStyle.new ()
style:setFont ( font )
style:setSize ( size )
return style;
end
textbox = MOAITextBox.new ()
textbox:setStyle ( newStyle ( font, 16 ))
textbox:setString ( text )
textbox:spool ()
textbox:setRect ( -128, -128, 128, 128 )
textbox:setAlignment ( MOAITextBox.CENTER_JUSTIFY, MOAITextBox.CENTER_JUSTIFY )
layer:insertProp ( textbox )
function onInput ( start, length, text )
print ( 'on input' )
print ( start, length, text )
print ( MOAIKeyboardAndroid.getText ())
end
function onReturn ()
print ( 'on return' )
print ( MOAIKeyboardAndroid.getText ())
end
MOAIKeyboardAndroid.setListener ( MOAIKeyboardAndroid.EVENT_INPUT, onInput )
MOAIKeyboardAndroid.setListener ( MOAIKeyboardAndroid.EVENT_RETURN, onReturn )
MOAIKeyboardAndroid.showKeyboard ()

Some Error Info:
libmoai.so (MOAIFrameBuffer::RenderTable(MOAILuaState&, int)+48)
libmoai.so (MOAIFrameBuffer::Render()+232)
libmoai.so (MOAIRenderMgr::Render()+240)

@ggsonic

here is my gdb backstrace info,might be helpful:
It seems that crash happens when calling lua_rawgeti. we got refer to address 0x0,and causing segfault.
Is this a lua's bug or just wrong use?

#0 0x529ec9dc in luaH_getnum (t=0x0, key=2) at /Users/xxx/git/moai-dev/ant/libmoai/jni/../../../3rdparty/lua-5.1.3/src/ltable.c:437........
No locals.
#1 0x529d3ce8 in lua_rawgeti (L=0x513ddb00, idx=7, n=2)
at /Users/xxx/git/moai-dev/ant/libmoai/jni/../../../3rdparty/lua-5.1.3/src/lapi.c:573
o2 = 0xfffffffe
o1 = 0x52decc34
o = 0x52c7a720
#2 0x5276e5e8 in MOAIFrameBuffer::RenderTable (this=0x50f7a0e8, state=..., idx=7)
at /Users/xxx/git/moai-dev/ant/libmoai/jni/../../../src/moaicore//MOAIFrameBuffer.cpp:366
valType = 7.
n = 3.
#3 0x5276e468 in MOAIFrameBuffer::Render (this=0x50f7a0e8)
at /Users/xxx/git/moai-dev/ant/libmoai/jni/../../../src/moaicore//MOAIFrameBuffer.cpp:335
state = { = {_vptr.MOAILuaState = 0x52cb9ef8, mState = 0x513ddb00}, mRestoreTop = 6}
gfxDevice = @0x512a3510
#4 0x528095e8 in MOAIRenderMgr::Render (this=0x50f7a8e8)
at /Users/xxx/git/moai-dev/ant/libmoai/jni/../../../src/moaicore//MOAIRenderMgr.cpp:172
device = @0x512a3510
#5 0x5271d9a4 in AKURender () at /Users/xxx/git/moai-dev/ant/libmoai/jni/../../../src/aku/AKU.cpp:314
No locals.
#6 0x52719378 in Java_com_ziplinegames_moai_Moai_AKURender (env=0x4edb2f10, obj=0x4142e238)
at /Users/xxx/git/moai-dev/ant/libmoai/jni/src/moai.cpp:373

No locals.
#7 0x4076dff4 in ?? ()
No symbol table info available.
#8 0x4076dff4 in ?? ()

@adamvillalobos

There was a threading issue that I believe is fixed in the latest on the android_keyboard branch. I'll be merging it in once I get a few other issues fixed.

@ggsonic

Great!this works for me! Thanks so much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment