Dreikblack Posted February 8 Share Posted February 8 1. New game 2. Esc to call menu 3. Press Main menu 4. Continue game 5. If no app is froze yet do paragraph 2 again. Usually it happens at 2nd continue game but often happen at 1st too, Same approach works for me in main C++ project, game.lua globals.lua main.lua Quote Link to comment Share on other sites More sharing options...
Josh Posted February 8 Share Posted February 8 I am unable to produce any error with these instructions. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Dreikblack Posted February 8 Author Share Posted February 8 Strange. Maybe a video will be useful Quote Link to comment Share on other sites More sharing options...
Josh Posted February 8 Share Posted February 8 Yes, that helped a lot. I did not know you were using that map. Now I can get the error. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted February 8 Share Posted February 8 It's not crashing. The main thread appears to be stuck in a loop maybe. Do you have a C++ program that produces this error? Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
reepblue Posted February 8 Share Posted February 8 2 minutes ago, Josh said: It's not crashing. The main thread appears to be stuck in a loop maybe. Do you have a C++ program that produces this error? I've noticed this issue too. Compiling the application not as a console application usually solves the issue. Quote Cyclone - Ultra Game System - Component Preprocessor - Tex2TGA - Darkness Awaits Template (Leadwerks) If you like my work, consider supporting me on Patreon! Link to comment Share on other sites More sharing options...
Josh Posted February 8 Share Posted February 8 Ohhh.. The fact that you are creating a new GUI inside an event callback really does not make me feel good. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted February 8 Share Posted February 8 Wait, you have this: ListenEvent(EVENT_WIDGETACTION, loadGameButton, loadGameButtonCallback) And this: local function loadGameButtonCallback(Event, Extra) if (game.world == nil) then do return end end -- world:Pause() GameLoop() -- world:Resume() end And then this: function GameLoop() if (game.isMainMenuOn) then -- game.world:Resume() end game.isMainMenuOn = false game.menuPanel:SetHidden(true) game.isMenuOn = false window:SetCursor(0) while window:Closed() == false and game.isMainMenuOn == false do Bro, you got loops within loops. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted February 8 Share Posted February 8 I don't know exactly what is going on here, but your program has a very confusing structure. I can't for sure see anything that is a problem, but I think your issue will go away if you get rid of the second game loop. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Dreikblack Posted February 9 Author Share Posted February 9 7 hours ago, reepblue said: I've noticed this issue too. Compiling the application not as a console application usually solves the issue. What was structure of app? 8 hours ago, Josh said: Do you have a C++ program that produces this error? I can try to replicate exactly same app in C++. 8 hours ago, Josh said: The fact that you are creating a new GUI inside an event callback really does not make me feel good. Why tho? Maybe this is a reason why i have no problem with similar structure in main project, i'm using lambdas instead of events for by buttons there. 8 hours ago, Josh said: Bro, you got loops within loops. I have two loops for two worlds. Loop inside of loop is just side effect of it What should be approach for few worlds? I will also to try do it with same loop for this case but i fail to see a problem beside issue that could be related to something else like ui created in event callback. Quote Link to comment Share on other sites More sharing options...
Josh Posted February 9 Share Posted February 9 In theory it should not matter, but you are calling a C++ function that then goes back into Lua, and there might be something weird I don't know about going on there, when you have layers of interfaces between the two. It makes me nervous. I tried pausing the program during execution, but it said the program was running external code, which makes me think it is stuck in the Lua library somehow. I also tried to pause from VSCode, but it could not pause. This supports the same hypothesis. The next thing I can do is build Lua into the engine as C++ instead of a compiled library, or maybe a debug build of the Lua lib, but I don't know if being able to pause inside the Lua VM will tell me anything useful. I don't think you will be able to recreate this problem in C++. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Dreikblack Posted February 9 Author Share Posted February 9 5 hours ago, Josh said: I don't think you will be able to recreate this problem in C++. I did it If pausing while inf. loop: Game.cpp Game.h main.cpp Quote Link to comment Share on other sites More sharing options...
Dreikblack Posted February 9 Author Share Posted February 9 Reproduced it even with one loop in one main.cpp file. Not creating game gui in callback this time. Have no idea what causing an issue now beside switching between worlds which is somehow working in my Quake Tactics project. btw you mentioned that no issue happens with other map - could be a problem related to player controller or something like that? #include "UltraEngine.h" #include "ComponentSystem.h" using namespace UltraEngine; shared_ptr<World> gameWorld; shared_ptr<Interface> gameUi; shared_ptr<Camera> uiCamera; shared_ptr<Map> gameScene; shared_ptr<Window> window; shared_ptr<Framebuffer> framebuffer; shared_ptr<Widget> menuPanel; bool isMenuOn = false; bool isMainMenuOn = true; bool resumeGameButtonCallback(const Event& ev, shared_ptr<Object> extra) { menuPanel->SetHidden(true); isMenuOn = false; return true; } bool mainMenuButtonCallback(const Event& ev, shared_ptr<Object> extra) { isMainMenuOn = true; return true; } bool newGameButtonCallback(const Event& ev, shared_ptr<Object> extra) { isMainMenuOn = false; return true; } bool exitButtonCallback(const Event& ev, shared_ptr<Object> extra) { exit(0); return true; } void guiInit() { // Load a font auto font = LoadFont("Fonts/arial.ttf"); // Create user interface gameUi = CreateInterface(gameWorld, font, framebuffer->GetSize()); gameUi->SetRenderLayers(2); gameUi->root->SetColor(0.0f, 0.0f, 0.0f, 0.0f); gameUi->LoadColorScheme("Resources/configs/Style.json"); // Create ui camera uiCamera = CreateCamera(gameWorld, PROJECTION_ORTHOGRAPHIC); uiCamera->SetPosition(float(framebuffer->GetSize().x) * 0.5f, float(framebuffer->GetSize().y) * 0.5f, 0); uiCamera->SetRenderLayers(2); uiCamera->SetClearMode(CLEAR_DEPTH); int menuWidth = 200; int menuHeight = 200; int indent = 25; menuPanel = CreatePanel(framebuffer->size.x * 0.5 - menuWidth / 2, framebuffer->size.y * 0.5 - menuHeight / 2, menuWidth, menuHeight, gameUi->root); menuPanel->SetColor(0.2, 0.2, 0.2, 1); menuPanel->SetLayout(1, 1, 1, 1); menuPanel->SetHidden(true); int buttonWidth = menuWidth - indent * 2; int buttonHeight = 50; int posIter = 0; int buttonY = indent + posIter * (buttonHeight + indent); auto resumeButton = CreateButton("Resume", indent, buttonY, buttonWidth, buttonHeight, menuPanel); ListenEvent(EVENT_WIDGETACTION, resumeButton, resumeGameButtonCallback); posIter = posIter + 1; buttonY = indent + posIter * (buttonHeight + indent); auto mainMenuButton = CreateButton("Main Menu", indent, buttonY, buttonWidth, buttonHeight, menuPanel); ListenEvent(EVENT_WIDGETACTION, mainMenuButton, mainMenuButtonCallback); } int main(int argc, const char* argv[]) { RegisterComponents(); //Load FreeImage plugin (optional) auto fiplugin = LoadPlugin("Plugins/FITextureLoader"); //Get the displays auto displays = GetDisplays(); //Create a window window = CreateWindow("Ultra Engine", 0, 0, 1280 * displays[0]->scale, 720 * displays[0]->scale, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR); //Create a framebuffer framebuffer = CreateFramebuffer(window); //Create a world auto world = CreateWorld(); //Load a font auto font = LoadFont("Fonts/arial.ttf"); //Create user interface auto ui = CreateInterface(world, font, framebuffer->GetSize()); ui->SetRenderLayers(2); ui->root->SetColor(0.2f, 0.2f, 0.2f, 1.0f); ui->LoadColorScheme("Resources/configs/Style.json"); //Create ui camera auto uiCamera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC); uiCamera->SetPosition(float(framebuffer->GetSize().x) * 0.5f, float(framebuffer->GetSize().y) * 0.5f, 0); uiCamera->SetRenderLayers(2); uiCamera->SetClearMode(CLEAR_DEPTH); auto newGameButton = CreateButton("New game", 200, 125, 200, 50, ui->root); ListenEvent(EVENT_WIDGETACTION, newGameButton, newGameButtonCallback); auto exitButton = CreateButton("Exit", 200, 200, 200, 50, ui->root); ListenEvent(EVENT_WIDGETACTION, exitButton, exitButtonCallback); gameWorld = CreateWorld(); gameWorld->RecordStats(); WString mapName = "Maps/start.ultra"; gameScene = LoadMap(gameWorld, mapName); guiInit(); shared_ptr<World> currentWorld = world; shared_ptr<Interface> currentUI = ui; while (window->Closed() == false) { if (isMainMenuOn) currentWorld = world; else currentWorld = gameWorld; if (isMainMenuOn) currentUI = ui; else currentUI = gameUi; if (window->KeyDown(KEY_ESCAPE) == true) { menuPanel->SetHidden(false); isMenuOn = true; window->SetMousePosition(framebuffer->size.x * 0.5, framebuffer->size.y * 0.5); } while (PeekEvent()) { const Event ev = WaitEvent(); switch (ev.id) { case EVENT_WINDOWCLOSE: if (ev.source == window) { exit(0); break; } break; default: currentUI->ProcessEvent(ev); break; } } currentWorld->Update(); currentWorld->Render(framebuffer); } return 0; } 1 Quote Link to comment Share on other sites More sharing options...
Dreikblack Posted February 9 Author Share Posted February 9 Removed player and added a usual camera to start map - no issues Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted February 9 Share Posted February 9 I just tried your example above and am getting the same result as you after a few clicks back and forth between new game and main menu. It's getting stuck somewhere weird. Quote Link to comment Share on other sites More sharing options...
Josh Posted February 9 Share Posted February 9 5 hours ago, Dreikblack said: Reproduced it even with one loop in one main.cpp file. You proved me wrong, sir. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted February 9 Share Posted February 9 It says sometimes it is stopping in wasapi.c, something to do with the Windows audio system, but I am not convinced this is right. > Ultra Engine_d.exe!`anonymous namespace'::WasapiPlayback::mixerProc() Line 719 C++ I commented out all the sound stuff but it still happens here...investigating... Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted February 9 Share Posted February 9 It seems like it is being caused by the player model or component somehow, because this scene with just a camera works fine: start.zip Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted February 9 Share Posted February 9 Okay, it looks like there is something going on with the animation system. If I comment that out I can load and reload with no issues, many times... Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted February 9 Share Posted February 9 Okay, I know where it is stuck. It is stopped waiting for a result from the animation thread that never comes... Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted February 9 Share Posted February 9 I can see the send / receive is out of sync. Sending Wait result OK Sending Wait result OK Sending Wait result OK Sending Sending Wait result OK Wait result Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Solution Josh Posted February 9 Solution Share Posted February 9 Okay, this was simply caused by the animation send state sort of getting out of sync when different worlds are used. Once I figured out what it was it was an easy fix. I think @Dreikblack deserves a big round of applause. 2 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Dreikblack Posted February 10 Author Share Posted February 10 Last C++ examples works fine now but initial LUA example still have same issue Quote Link to comment Share on other sites More sharing options...
Josh Posted February 10 Share Posted February 10 I just updated again, to make sure the right thing got uploaded. Please try it and make sure you updated your project, I tried your original Lua example with no problems. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Dreikblack Posted February 10 Author Share Posted February 10 With newest update Lua example works now as well, 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.