Issues related to Map initialization + Elapsed time + Minimized game

Uncle

Warcraft Moderator
Level 76
Joined
Aug 10, 2018
Messages
8,351
Edit: Found the problem, it was oddly specific to the tools I use. But this may still be worth reading if you're interested.

Hello friends, this may be an already documented issue but I want to discuss it here. This is in regards to the loading process (Map initialization) and what can go wrong there.

First off:
1. I play in Borderless Window mode.
2. I'm testing my map offline.
3. I'm on the latest patch.
4. I'm in Lua-mode.
5. I'm launching my map from Visual Studio using the WCSharp library: Home.

The problem is that some Actions fail to run, or that's my suspicion. This appears to only happen if I'm minimized when the map finishes loading. I have a habit of alt-tabbing a lot, so often times I'll finish loading -> press a key to proceed -> and alt-tab in basically the same frame.

One issue in particular is from these triggers:
  • Map Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Cinematic - Disable user control for (All players).
      • Cinematic - Fade out over 0.00 seconds using texture Black Mask and color (0.00%, 0.00%, 0.00%) with 0.00% transparency
  • Map Start
    • Events
      • Time - Elapsed game time is 0.50 seconds
    • Conditions
    • Actions
      • Cinematic - Enable user control for (All players).
      • Cinematic - Fade in over 0.10 seconds using texture Black Mask and color (0.00%, 0.00%, 0.00%) with 0.00% transparency
The "Enable user control" Action in Map Start will fail to run and my control will be disabled permanently. Again, this seems to only happen if I'm minimizing/maximizing during the Loading process, and what I assume would be within a short window of time between transitioning from that screen into the game.

This could also be related to WCSharp which I mentioned above. I'm currently trying to replicate the issue when launching the map from the World Editor instead of through that tool, and I'll edit this with a confirmation soon.

Edit 1: After testing some more, it seems like the issue happens even if I use Elapsed Time events instead of Map Initialization. Also, I'm pretty certain it's directly related to WCSharp, it seems like my Main() function - which is meant to run when the game starts, is not running if I'm minimized.

Edit 2: I've managed to remedy it a bit. I deleted the "Disable user control" stuff and found that what's happening is the game gets locked in a paused state. I can't move my camera or click anything, but I can open menus. If I open say the Message Log, and then close it, the game is resumed and the rest of my logic runs without issue. So this appears to be a Singleplayer-only issue which I can remedy with some frame manipulation. The "Resume game" action didn't work for whatever reason... It's a like a pseudo-Pause.

Edit 3: An example of the remedy (again, this may only pertain to WCSharp users):
  • Map Initialization
    • Events
      • Time - Elapsed game time is 0.01 seconds
    • Conditions
    • Actions
      • Custom script: print("--- MAP INIT ---")
      • -------- --------
      • -------- This is a fix to a rare "pause" glitch that happens in SP testing: --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of players in (All players)) Equal to 1
        • Then - Actions
          • Custom script: local origin = BlzGetOriginFrame(ORIGIN_FRAME_SYSTEM_BUTTON, 2)
          • Custom script: BlzFrameClick(origin)
          • Custom script: local closeBtn = BlzGetFrameByName("LogOkButton", 0)
          • Custom script: BlzFrameClick(closeBtn)
        • Else - Actions
      • -------- --------
      • Wait 0.01 game-time seconds
      • // I run a bunch of triggers here to finish the setup process (hidden to keep this post clean)
Side note: I've read and experienced issues in regards to custom UI frames (framehandles) and Map init. Perhaps these issues are similar. I delay the creation/manipulation of frames until some time has passed after Map Initialization is complete, but even then I seem to suffer from desyncs in multiplayer every so often. I wonder if the solution would be to have some kind of "Is everyone maximized" check running at the start of the game, that must be confirmed before any of this "dangerous" logic runs.

Any ideas? Also, thank you for your time :D
 
Last edited:
WC3 having an existential crisis when you alt-tab during load :goblin_boom:

I wouldn’t rely on timers for critical logic, maybe delay the timer until engine actually ticks at least once.
Maybe try adding a failsave to re enable control.
Lua-ish code that maybe would help, Im typing from phone away from my pc so i didnt get to tests this:

TimerStart(CreateTimer(), 0.00, false, function()
-- safe init here (runs when game loop actually ticks)
EnableUserControl(true)
end)


and maybe a backup


TimerStart(CreateTimer(), 2.00, false, function()
EnableUserControl(true)
end)



If i remember correctly frame API is local, so I suppose different focus states = potential desync

Was thinking something like this
Events
Time - Elapsed game time is 0.05 seconds
Conditions
(Number of players in (All players)) Equal to 1
Actions
Custom script: local origin = BlzGetOriginFrame(ORIGIN_FRAME_SYSTEM_BUTTON, 2)
Custom script: BlzFrameClick(origin)
Custom script: local closeBtn = BlzGetFrameByName("LogOkButton", 0)
Custom script: BlzFrameClick(closeBtn)
Cinematic - Enable user control for (All players)
// ... rest of your setup

Also Im not sure that game actually pauses when minimized, whenever i did that it felt like a pseudo-pause. Some of my main loops and functions were ‘paused’ but others were running fine. Feels like the engine is splitting focus. And Id assume this is all related to how the wc3 engine operates. Ill try testing this when I get home, it’s good that u reminded me of this cuz I disregarded this as engine limitation before. Many regards Uncle
 
Also Im not sure that game actually pauses when minimized, whenever i did that it felt like a pseudo-pause. Some of my main loops and functions were ‘paused’ but others were running fine. Feels like the engine is splitting focus. And Id assume this is all related to how the wc3 engine operates. Ill try testing this when I get home, it’s good that u reminded me of this cuz I disregarded this as engine limitation before. Many regards Uncle
I believe Wait actions (non game-time) will continue to run even while the game is "paused". That's likely what you were experiencing.
 
Back
Top