ptitSeb / Eldritch

Eldritch port to the OpenPandora (meaning Arm / GLES2 / OpenAL): Status Working (with latest data file from Steam)
https://boards.openpandora.org/topic/18323-eldritch/
Other
3 stars 2 forks source link

AmigaOS4 : Crash when exit from game, or restart, or when switch a level #5

Closed kas1e closed 3 years ago

kas1e commented 3 years ago

When I exit from a game we crash all the time because it tries to save ./main.eldritchmastersave" and says Couldn't open file ./main.eldritchmastersave, and then crashes with stack tracepoint out to the EldritchSaveLoad_SaveMaster. The same happens when we trying to restart a level, or when we go to the next world. For AmigaOS4 we need to put that file to the "PROGDIR:" (without ./ at the beginning), or to PROGDIR:.eldritch.

kas1e commented 3 years ago

Ok, now, when we exit from a game, we have "main.eldritchmastersave" file created in the PROGDIR:.eldritch (the same as prefs.cfg), but now it crashes on exit after doing "shutting down framework", in the ogles2.library, with such stack trace:

ShaderManagerFreeShaders->ShaderProgram->crash in ogles2.library

kas1e commented 3 years ago

Also it crashes now when trying to load "main.eldritchmastersave", in the SaveLoad_MasterDataStream->ColorGradingTexture SimpleSTring->SimpleString

kas1e commented 3 years ago

Probably when it tries to load back "main.eldritchmastersave" it needs to be "byte-swapped" read as well?

ptitSeb commented 3 years ago

The crash in ogles2.library: I don't see anything suspicious in the code.

kas1e commented 3 years ago

Currently, I just commented out in shadermanagment.cpp:

void ShaderManager::FreeShaders() {
#ifndef __amigaos4__
  FOR_EACH_MAP(ProgramIter, m_ShaderPrograms, SShaderProgramKey,
               IShaderProgram*) {
    SafeDelete(ProgramIter.GetValue());
  }

  FOR_EACH_MAP(VSIter, m_VertexShaders, HashedString, IVertexShader*) {
    SafeDelete(VSIter.GetValue());
  }

  FOR_EACH_MAP(PSIter, m_PixelShaders, HashedString, IPixelShader*) {
    SafeDelete(PSIter.GetValue());
  }
#endif
}

So it works, though it brings after a more easy crash: AL lib: (EE) alc_cleanup: 1 device not closed.

And have a warning window with "parent process has tried to exit before all children have". Error process "alsoft-mixer".

And stack tracepoint out on "ALCplaybackAHI_mixerProc"

kas1e commented 3 years ago

Also find out compile error from last commit:

/amiga/Eldritch/code/Libraries/Workbench/src/Components/wbcomptransform.cpp:51:10: error: redeclaration of ‘Vector tmp’
   Vector tmp = m_Velocity;
ptitSeb commented 3 years ago

But you create a GPU memory leak by commenting this code, IIRC the amiga OS doesn't clean leftover stuff automatically.

For openal: all the closing code is here: Look at Code/Libraries/Audio/src/openalaudiosystem.cpp from line 42 to 53. The OpenALAudioSystem destructor close the context and the device properly.

ptitSeb commented 3 years ago

maybe just the alutExit() should be placed just after alcMakeContextCurrent(nullptr)?

kas1e commented 3 years ago

Yeah, it at least, of course, I just comment it out currently for not crash on exit all the time for better tests until main things done.

As for compile error i change it like:

  #if __amigaos4__
  Vector tmp = m_Location;
  littleBigEndian(&tmp.x);
  littleBigEndian(&tmp.y);
  littleBigEndian(&tmp.z);
  Stream.Write(sizeof(Vector), &tmp);
  Vector tmp2 = m_Velocity;
  littleBigEndian(&tmp2.x);
  littleBigEndian(&tmp2.y);
  littleBigEndian(&tmp2.z);
  Stream.Write(sizeof(Vector), &tmp2);
  #else
  Stream.Write(sizeof(Vector), &m_Location);
  Stream.Write(sizeof(Vector), &m_Velocity);
  #endif

And it compiles ok.

Then another typo:

wbcompeldplayer.cpp:1762:38: error: expected ‘}’ at end of input
   Stream.Write(sizeof(Vector), &vtmp);
                                      ^
kas1e commented 3 years ago

Also wbcompeldtransform.cpp:

/wbcompeldtransform.cpp:332:20: error: ‘tmp’ was not declared in this scope
   littleBigEndian(&tmp.x);
kas1e commented 3 years ago

And:

Components/wbcompeldplayer.cpp:1757: error: unterminated #else
   #ifdef __amigaos4__
kas1e commented 3 years ago

wbcompeldtrapbolt.cpp:262:20: error: expected ‘;’ before ‘littleBigEndian’ , forgotten ";"

and then:

/amiga/Eldritch/code/Projects/Eldritch/src/eldritchworld.cpp:2063:24: error: ‘struct SVoxelIrradiance’ has no member named ‘x’
   littleBigEndian(&tmp.x);
                        ^
/amiga/Eldritch/code/Projects/Eldritch/src/eldritchworld.cpp:2064:24: error: ‘struct SVoxelIrradiance’ has no member named ‘y’
   littleBigEndian(&tmp.y);
                        ^
/amiga/Eldritch/code/Projects/Eldritch/src/eldritchworld.cpp:2065:24: error: ‘struct SVoxelIrradiance’ has no member named ‘z’
   littleBigEndian(&tmp.z);
                        ^
/amiga/Eldritch/code/Projects/Eldritch/src/eldritchworld.cpp:2066:24: error: ‘struct SVoxelIrradiance’ has no member named ‘w’
   littleBigEndian(&tmp.w);
                        ^
kas1e commented 3 years ago

Yeah, now compiles, through give the same crash when i tries to run game and it loads master-slave file (on the same SimpleString() stuff)

ptitSeb commented 3 years ago

You probably need to erase the provious state first.

kas1e commented 3 years ago

Yeah, done that of course, still crashes :(

kas1e commented 3 years ago

Will try to rebuild the whole source from scratch from the repo just in case

kas1e commented 3 years ago

Rebuild all from scratch, delete all content from .eldritch directory fully, run game, exit: file creates. Then run the game again and that crash :( And in the console I had that:

S/L: Flushing world files:
Assertion failed: "Iter.ISBalid()" ()
in unknown function in code/Libraries/Core/src/map.h at line 554
Assertion failed: "m_Node" ()
in unknown function in code/Libraries/Core/src/map.h at line 69
ptitSeb commented 3 years ago

I fixed the saving of HashedString, that may explain all those crashes.

kas1e commented 3 years ago

Thanks! Need to go for a hour, once will back will check everything

kas1e commented 3 years ago

Tested latest commit: yeah! Didn't crashes anymore! Now to understand why it crashes on exit when free shaders and close audio stuff (will create another ticket about)