Planimeter / game-framework

Planimeter Game Framework - LuaJIT FFI-based game development framework for Lua
MIT License
89 stars 3 forks source link

'too many callbacks' #8

Closed revolucas closed 4 years ago

revolucas commented 5 years ago

When loading multiple models it crashes with 'too many callbacks'

E:\GameDevelop\lgameframework\luajit.exe: ...eDevelop\lgameframework\lua\framework\graphics\model.lua:59: too many callbacks stack traceback: ...eDevelop\lgameframework\lua\framework\graphics\model.lua:59: in function <...eDevelop\lgameframework\lua\framework\gr aphics\model.lua:55> [C]: in function 'aiImportFileEx' ...eDevelop\lgameframework\lua\framework\graphics\model.lua:197: in function 'constructor' E:\GameDevelop\lgameframework\lib\class.lua:126: in function 'newModel' .\main.lua:64: in function 'load' E:\GameDevelop\lgameframework\lua\framework\init.lua:92: in function 'main' E:\GameDevelop\lgameframework\lua\framework\init.lua:275: in main chunk [C]: at 0x7ff63c054aa0 AL lib: (EE) alc_cleanup: 1 device not closed Press any key to continue . . .


EDIT: It is related to: http://luajit.org/ext_ffi_semantics.html#callback

Seems there is a limited amount of callbacks you can create.

revolucas commented 5 years ago

Okay, the solution is simple in PHYSFSCloseProc free them: `
file.ReadProc:free()

file.WriteProc:free()

file.TellProc:free()

file.FileSizeProc:free()

file.SeekProc:free()

file.FlushProc:free() `

Also, according to the callback wiki it might be safer to jit.off() before aiImportFileEx and jit.on() again after.

andrewmcwatters commented 5 years ago

Got it. I'll check this out!