Have you used LuaJit with Gideros and, if so, was the effort worth the performance increase in your case? I'd love to hear details about what kind of game you used it in, and exactly how it improved the performance.
Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!). https://deluxepixel.com
i tried now to add luajit to my android project and it crashes. i disabled json as maybe they don't work together, but still i get white screen for a short time and immediate crash. any ideas what may cause this? does luajit work for you in android? (in the windows player it works fine for me)
Hey @sinistersoft, do you have an example of when LuaJIT has made a difference, in your experience? I'm trying to figure out in what scenario it would be most useful.
I'm not going in head first because adding something magical like LuaJIT adds another question mark if when troubleshooting issues.
@totebo I think it's worth a try since it's really easy to switch it on and off. The "biggest" job is compiling a jit giderosandroidplayer for live testing, but I found it better to compile a test apk embedding jit libs to check its impact.
There is only one requirement in coding I am aware of (you don't need to change it back , works in plain lua too) it's stated somewhere in this forum: if I recall it correctly it was something about function arguments like in
function myfunc(arg)local arg = arg --you need to localize argend
Or something about
function myfunc (...) usage - which I've never used personally because I didn't understood how to use it.. but is there in some lua lib that you may load
I'm sorry I can't check this right now without laptop nor wifi: search the forum for luajit and my notes (if I am right it was in a post from gregbug about tnt particle system)
At this time in my game luajit it's not so worth (longer loading time, everything is a bit smoother, but on a single multiple pathfinding action there is a loong delay - I use jumper, but I suppose it's my fault since I use jumper in other actions and I don't have such delays. Plus, I'd like to support also older devices, every delay on these is doubled and there was no appreciable improvement overall). I've not given it up though, it does seem to increase performance on newer devices, not tested thoroughly yet. maybe in a near future I'll think about it again.
@keszegh I can use json along with luajit and it's not crashing (android 4.4) I believe the "damage" is somewhere else in what you do with loaded data (or some "coding requirement" - see above)
@pie, thanks for your comments. well, if localization is necessary then that might be an issue for me too, i have plenty of functions without localizing the arguments. on the other hand jit version of windows player seems to be working fine with the same project.
Not exactly a localization, but lua automatically creates local variable arg holding table of all passed paraeters, then in luajit it does not, and you have to do something as:
function test(...)--if function relies on arg variable, it won't exist here and you need to create it yourselflocal arg ={...}end
well, i see no appearance of 'arg' in any of the lua files i use (scenemanager, gtween, aceslide). do you have any common used library that you remember that might have this issue?
@pie, @ar2rsawseen, thanks for the tips, mobdebug was the only thing that had "..." in it, i deleted it from my project but still when i copy over the luajit lib to plain lua lib, the game starts with a short time of white screen and then quits.
@ar2rsawseen, thanks for finally guessing what went stupid. now it works of course I read only the 'android' part and did not realize that the 'windows installation' part also has to be done for exporting to android properly.
now that it works this way, I realize that it's a slight drawback with luajit that the lua files are completely exposed (encrypting is also not possible of them while using luajit). it's a bit more surprising for me that also the asset files cannot be encrypted - if i encrypt, then again it is not working. so everything is exposed.
this may be enough for me to stay with plain lua as the performance gain might not be needed for me.
@ar2rsawseen, both code and assets can be encrypted? that's great (for me it did not work, but it's hard to check when am i running what in eclipse, so i will try more then, perhaps i messed up something else)
@totebo When the code starts (with LuaJIT) there is a slight delay over a normal Lua program - this must be the compile stage - on most phones this is not noticable though.
Other than that I'd say everything is faster - no complaints here.
On a side note, the encryption with Gideros needs to be revisited as it's pretty easy to auto hack it out.
Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!). https://deluxepixel.com
I agree, right now it is trivial to decrypt gideros lua files. I'm planning on updating the encryption part so the decryption key isn't stored in plaintext at the same relative location in every app, and builds unique encryption/decryption code that is different for every installation of gideros.
Of course - I don't know how the framework stores lua code in memory. If you load an apk in an emulator and take a memory dump - how easy is it to access the original code even if it was encrypted?
Access to source code may not be that important to some, except for retrieval of private keys used for encryption/public api access, etc.
If you use luaJit, then today I can take your apk and recreate your exact project with original source lua+all assets. If you don't, it's more time consuming because I have lua byte code to deal with, some of which cannot be automatically decompiled.
@alexzheng It's compiled on the machine (JIT) otherwise it's still interpreted.
@EricCarr Lua files have a header, so do other picture files - using this it's possible to figure out the XOR as it's too short before it repeats (it's about the same size as the Lua header that never changes!).
Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!). https://deluxepixel.com
Just to give my experience, I did not notice any difference in speed running with Lua JIT versus the normal runtime. I was running a simple platform game which is probably not very Lua intensive anyway (see links). My impression is that Lua is already pretty fast and modern hardware is fast, so unless you are inverting matrices or something, you may not notice much difference.
@sinistersoft the xor key is stored directly after a hard coded (never changes) series of bytes, so it can just be read to decrypt all files without needing to bother with brute force. I was wondering if lua keeps the lua byte code as-is in memory so getting by any encryption is as simple as taking a memory dump of an emulator.
One thing is for sure - the existing method needs to be changed.
Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!). https://deluxepixel.com
Comments
https://deluxepixel.com
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Fragmenter - animated loop machine and IKONOMIKON - the memory game
I'm not going in head first because adding something magical like LuaJIT adds another question mark if when troubleshooting issues.
There is only one requirement in coding I am aware of (you don't need to change it back , works in plain lua too) it's stated somewhere in this forum: if I recall it correctly it was something about function arguments like in
function myfunc (...) usage - which I've never used personally because I didn't understood how to use it.. but is there in some lua lib that you may load
I'm sorry I can't check this right now without laptop nor wifi: search the forum for luajit and my notes (if I am right it was in a post from gregbug about tnt particle system)
At this time in my game luajit it's not so worth (longer loading time, everything is a bit smoother, but on a single multiple pathfinding action there is a loong delay - I use jumper, but I suppose it's my fault since I use jumper in other actions and I don't have such delays. Plus, I'd like to support also older devices, every delay on these is doubled and there was no appreciable improvement overall).
I've not given it up though, it does seem to increase performance on newer devices, not tested thoroughly yet. maybe in a near future I'll think about it again.
@keszegh I can use json along with luajit and it's not crashing (android 4.4) I believe the "damage" is somewhere else in what you do with loaded data (or some "coding requirement" - see above)
Hope this helps
Likes: ar2rsawseen
well, if localization is necessary then that might be an issue for me too, i have plenty of functions without localizing the arguments. on the other hand jit version of windows player seems to be working fine with the same project.
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Likes: pie
is luajit working with android fine for everybody?
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Fragmenter - animated loop machine and IKONOMIKON - the memory game
I don't remember editing any file on your list for this issue, I used them all.
If I recall correctly I had issues (easily solved) with the following libs and luajit:
progressbar by @ar2rsawseen
An outdated release of tnt particle system (latest already fixed)
And, to use Tnt animator by @gregBUG with luajit you need its source file
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Installation mobiles
Prerequisites
To make mobile project work with LuaJIT you need to make some changes to Gideros Installation and reexport the project's assets again
Windows installation
Mac OSX installation
Android
Copy libs folder from luajit folder into your exported project overriding existing liblua.so files
IOS
Copy liblua.a from luajit folder into your xCode's project folder overriding existing liblua.a
of course I read only the 'android' part and did not realize that the 'windows installation' part also has to be done for exporting to android properly.
now that it works this way, I realize that it's a slight drawback with luajit that the lua files are completely exposed (encrypting is also not possible of them while using luajit). it's a bit more surprising for me that also the asset files cannot be encrypted - if i encrypt, then again it is not working. so everything is exposed.
this may be enough for me to stay with plain lua as the performance gain might not be needed for me.
@ar2rsawseen, @pie, thanks for your help
Fragmenter - animated loop machine and IKONOMIKON - the memory game
(for me it did not work, but it's hard to check when am i running what in eclipse, so i will try more then, perhaps i messed up something else)
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Other than that I'd say everything is faster - no complaints here.
On a side note, the encryption with Gideros needs to be revisited as it's pretty easy to auto hack it out.
https://deluxepixel.com
Likes: SinisterSoft
Of course - I don't know how the framework stores lua code in memory. If you load an apk in an emulator and take a memory dump - how easy is it to access the original code even if it was encrypted?
Access to source code may not be that important to some, except for retrieval of private keys used for encryption/public api access, etc.
If you use luaJit, then today I can take your apk and recreate your exact project with original source lua+all assets. If you don't, it's more time consuming because I have lua byte code to deal with, some of which cannot be automatically decompiled.
Likes: SinisterSoft
https://sites.google.com/site/xraystudiogame
@EricCarr Lua files have a header, so do other picture files - using this it's possible to figure out the XOR as it's too short before it repeats (it's about the same size as the Lua header that never changes!).
https://deluxepixel.com
https://github.com/gideros/gideros
https://www.youtube.com/c/JohnBlackburn1975
Niclas
One thing is for sure - the existing method needs to be changed.
https://deluxepixel.com