-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RuntimeException when loading a saved game #8
Comments
Is this behavior only on a special cartridge? |
I didn't test with other cartridges, I admit. "Reverse Wherigo" from -Waldmeister- works fine, also another cartridge I downloaded just now. I used Android 8 and the cartridge "Die Prüfung der Magier". The error message can be reproduced every time when loading a savegame of this cartridge. I'll try and see if I can debug this with AS - alas I fear that I will enter rocky paths when entering the LUA part. |
No fear, it is all java. As info, the migration to kahlua2 was never finished. |
I managed to connect to my device. It was just as easy as when I joined Google Dev Camp quite a few years ago. 😉
I am sure that the cartridge is the problem. I know the owner so I could ask for the source.
Maybe the obfuscation is to be blamed.
Am 3. April 2020 14:12:26 MESZ schrieb Bernd <[email protected]>:
…No fear, it is all java.
It uses a java port for lua - kahlua: https://github.com/krka/kahlua .
It is a fork directly integrated in openWIG.
As info, the migration to kahlua2 was never finished.
--
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub:
#8 (comment)
|
I contacted the cartridge owner and received the urwigo project yesterday. Commencing debug initialization sequence... zehn... neun... acht... sieben... sechs... fünnef... |
... and now the result: |
After a long series of tests I have to refine my last answer - which is obviously not correct. At least there were some circumstances that made it seem so. Shame on me. I have created a skeleton Wherigo cartridge using Urwigo which crashes after reloading a saved game (regardless whether saved to a savegame slot or just normal backup saving after quitting a running game). The cartridge consists of just one task, When the cartridge is started, the task changes to "completed". inside the cartridges onStart() event. When starting a new game everything works just as expected, no error message is shown - so I think kahlua isn't broken. The Urwigo project is attached as a text file which can [easily be renamed to "Crash.urwigo" and] opened with Urwigo for test purposes. It is reduced to the very spot where the error occurs when restoring the saved state. The issue occurs when openwig tries to read (or does it execute?) the LUA source line 316 of the compiled (!) LUA code which reads "objCrash.Active = false". I am very confused why this happens while RESTORING a saved cartridge, because executing this line obviously does not crash. Update: Made some minor changes so that the cartridge starts inside Urwigo emulator as well as using WhereYouGo. I also added a dummy task that stays active and displayed for some reasons not regarding the issue, just to run as expected in Urwigo emulator. The links below reflect those changes. @bekuno: could you dive into this? My knowledge of openwig is very limited. There are a few issues in openwig referring to this problem. Especially this one: Issue #245 Here are some files to reproduce the error: |
Here's what I debugged so far. I was using a cartridge created by Earwigo this time. The GWC file shows the same behaviour which means that it is not a Urwigo problem. The cartridge was compiled online by the Groundspeak wherigo compiler - the LUA code for OnSetComplete in this case resides in line 266 (see below). Savegame.java uses deserializeLuaTable() to read the saved state of the cartridge. After a lot of deserializing it reads the LUA code for the function OnSetComplete, which seems to be OK. Right after that I think it reaches the point of reading the saved state of the task which is "Complete".
In the call of tableSet() aObj is null, consequently in LuaState.java line 1213 the following assertion fails:
I am quite sure that, while reading the saved state, openwig gets confused and runs LUA code instead continuing reading the saved file. The call of table.rawset() in Savegame.java should not run setItem() which in turn runs callEvent(). Here's some code from EventTable.java:
The TODO tag does sound a bit like unfinished code. The last entry about openwig on matejcik's techblog is
I think the feature of restoring from a saved game is quite shiny and new, maybe it leads to the aforementioned problem, but definitely should not lead to actually running cartridge code. Could someone (@Lineflyer, @matejcik, @biylda) who is able to understand, verify and correct the problem dig into the details? |
My humble suggestion to the problem described in the above comment: Savegame.java: call of table.rawset() with additional parameter:
and additionally refactoring the methods in EventTable.java:
This should hopefully do the trick. |
created Pull Request #10 |
What a catch! this must have existed ever since The reason for this is actually here: public void serialize (DataOutputStream out) throws IOException {
Engine.instance.savegame.storeValue(table, out);
}
public void deserialize (DataInputStream in) throws IOException {
Engine.instance.savegame.restoreValue(in, this);
//setTable(table);
} when serializing, the Of course there is a reason for using Which is also why your PR #10 is incorrect: it breaks this functionality. A slightly better fix would be something like: private boolean isDeserializing = false;
public void deserialize(...) {
isDeserializing = true;
savegame.restoreValue(in, this);
isDeserializing = false;
}
public void callEvent(...) {
if (isDeserializing) return;
// ...
} an actually correct fix is to change public void deserialize(...) {
savegame.restoreValue(in, table);
visible = table.rawget("Visible");
active = table.rawget("Active");
// etc...
} and do this for all subclasses. Of course, the reason we have setItem in the first place is for performance; on J2ME phones I didn't want to do a hashtable lookup for what could have been a property access. |
I have rewritten the code in EventTable.java as suggested by matejcik (see "A slightly better fix" above). Pull Request is underway. |
After saving a game (regardless whether to a save slot or normal) and restarting with a saved game following rror message gets displayed:
Reproduce as follows:
The messages is displayed every time a cartridge is started from a saved game. It is dsplayed only a short fraction of a second but is still displayed when you quit the cartridge. The message is generated in cz.matejcik.openwig.Engine.stacktrace().
I think it originates from Engine line 210 when calling restoreGame(). I don't think restoreGame does throw an IOException, as this would have resulted in a different message.
WhereYouGo version 2020.03.08
The text was updated successfully, but these errors were encountered: