Hello
I have hundreds lua crashes in my game(may be games)
com.giderosmobile.android.player.LuaException: C:/export/sostavslovo/assets/assets/json.lua.jet:273: Nil string: ''
stack traceback:
C:/export/sostavslovo/assets/assets/json.lua.jet:273: in function <C:/export/sostavslovo/assets/assets/json.lua.jet:269>
(tail call): ?
C:/export/sostavslovo/assets/assets/datasaver.lua.jet:56: in function 'loadValue'
C:/export/sostavslovo/assets/assets/main.lua.jet:189: in main chunk
at com.giderosmobile.android.player.GiderosApplication.throwLuaException(GiderosApplication.java:1013)
at com.giderosmobile.android.player.GiderosApplication.nativeDrawFrame(GiderosApplication.java)
at com.giderosmobile.android.player.GiderosApplication.onDrawFrame(GiderosApplication.java:557)
at com.giderosmobile.android.GiderosRenderer.onDrawFrame(sostavslovoActivity.java:268)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1542)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1266) |
189 row is a
data = dataSaver.loadValue("data") |
I don't know what to do and why it happens.
Comments
A similar error happens to me when I update my savefile with some entry and I auto load a savefile generated with a previous release of the game.
You could try removing data.json from |D| folder and let your game write a new one, or open it with text or json editor and check it for "strange" nil strings.
You could also put a print () in datasaver to check which value is causing troubles
It seems you are using quite old version of dataSaver.lua then.
But yes, basically the problem is that you are passing empty string "" to json decode.
The way dataSaver works is that it reads value and checks if it is nil, and if not try to decode it with json. And next time when you save the value it encodes it as json.
So expected values are json string or nil, that dataSaver can handle.
Somehow, for some reason, you have saved empty string instead of nil or json string and it stumbles on it
Thanks. I can't open file or put "prints" because i don't have devices with that error. It happens on user devices.
Btw i'm pretty sure that i'm not saving any strings to "data". But i'm saving links that loads from web to another datasaver value.
Anyway. If i'll use new datasaver(where can i get it?) and json plugin - will it help?
Can i put some checks to prevent crashes?
datasaver github repo contains datasaver which uses native json
But I don't think it would solve the problem, unless we understand where the problem comes from.
Maybe users modify files directly?
One way to handle it is to use pcall to safely call function (it is like try and catch block in lua).
A way with pcall will cause losing all user progress. It is like uninstall and install.
Use json native plugin.
I don't know why, but sometimes app crashes on:
https://deluxepixel.com