Posted: 11th Jul 2024 17:41
Hi,
Old-school folks here might remember me, I'm the creator of Approaching Infinity, probably the biggest game (size-wise) ever created with AppGameKit Classic.
https://store.steampowered.com/app/551620/Approaching_Infinity/

Many of my players experience this issue:

When they alt-tab, or sometimes even just minimize or click some other app, the game appears to be running, but all input stops responding (keyboard and mouse clicks don't register).

Please help. I've tried a lot of things but nothing works.
Posted: 11th Jul 2024 18:24
is there any connection to win11 as suggested HERE or is it across the board?
Posted: 11th Jul 2024 19:44
Hey Virtual Nomad, yeah, you're in there

Well I mean that's my game, and that's my issue, and some players report it but majority don't, it certainly doesn't happen all the time, at least to me.

But I scoured AGK's command list for commands about focus or pause or resume, and I'n trying what I can think of, but that guy is still having a problem.
It could be a hardware or configuration problem on the user's end, but player's don't like to hear that kind of answer IYKWIM

Let me ask you, is there a known issue with windows 11 and USB ports? Could it be not related to my game or AppGameKit?

Also, i wonder if its some kind of RAM issue. as in, my game surely takes up a lot of working memory, so maybe there's some threshold over which that problem gets much worse?
Posted: 11th Jul 2024 20:43
i really have no idea and was hoping they were a 1-off but you advised "Many of my players experience this issue" and wondered if they were all on WIN11 or some other commality. is there a community thread on steam regarding the issue so we can have some more to go on?

my first question is, when users tab back to AI, is it actually still running the loops or simply sitting there and perhaps not ever getting Sync()'d. ie, just because the music is playing, i believe that's handed off @ Play() and then handled by WIN, not AI (no proof but that's always been my impression). if you could test that it's still Sync()ing, that would be a start. example could be to simply print FPS as we tend to do when testing our stuff. if that's getting updated, at least you know Sync() is happening (another more-subtle way is to not Loop music but check if it's still playing and start it again if it isnt. if they return to silence, it's not sync'ing?).

with that, are you using GetResumed() at all to perhaps reset anything that might need to be?

otherwise, without knowing what you might be doing under the hood... like, is there a loop waiting for a GetPointerReleased() that's never registering or was missed so it just sits there? are you using GetCharBuffer() vs manually testing KeyPressed, etc? just anything you could suggest where an issue may lay might help.

AGK is so forgiving of some of our less-than-ideal coding practices, otherwise, and that's great until we find ourselves in this situation, IMHO.

meanwhile, i dont venture outside the AppGameKit realm (and do nothing as complex as AI might be) but this is the first i've heard of this issue here or on discord, github, etc.. beside, perhaps, losing Controller input, but zero re: WIN11 vs USB and it's troubling that it appeared "fixed" in the thread i linked to for it only "break" again.

ps: has anyone experiencing the issue tried an older compatability mode? i just really wanna peruse any previous discussion/sleuthing if it exists somewhere?

add: if that thread on AI's discord is the only real discussion on that matter, there's not a lot for you to go on but i appreciate your trying to resolve for the couple/few experiencing it and it's great to see an AppGameKit game in active development, as well. there aren't many of AI's size that i'm aware of. perhaps you could reach out to SFSW who is the most-visible experienced AppGameKit dev that i know is actively developing.
Posted: 12th Jul 2024 2:04
Every version of Agk has always permafroze after an alt tab for for me on win 7 8 and 10 only seems to resume on very simple programs that are text based.
Posted: 12th Jul 2024 4:23
Well, let's forget the "WIN11 vs USB" thing, that's 3rd party conjecture.

I have no instances of GetPointerReleased() or GetCharBuffer() , but are there other things with similar behavior?

Today I experimented with this code to print "paused" while it's paused . 99.9% of all syncs come to the same place, so I stuck it in there.

+ Code Snippet
	while GetPaused()  
			print("Might Pause")
			sync()
		while GetResumed()=0 
			print("Pause")
			sync()
		endwhile
		` RestoreApp() <- this makes it un-minimize-able.
	endwhile

so, it works until you minimize the window. after that, it prints the "might pause", but immediately breaks the next loop, as if "getresumed" is permanently set to 1/true.
Also, restore app as I have it there, immediately maximizes the game as soon as you minimize it.

There is not a specific thread, and I haven't noticed commonalities between reports. Generally, some users report "freeze when alt-tab", etc. , and I say "that's a known issue and I don't know how to fix it".
Posted: 20th Aug 2024 0:03
I think those functions just read a variable and do not consume/reset the content so you would need to manage that yourself to "trap" the actual event and restore the app accordingly

untested but maybe something like
+ Code Snippet
state as integer
state = 0
if GetPaused() and state = 0  
	state = 1
	print("Pause")
endif

if GetResumed() and state = 1 
	state = 0
	RestoreApp() // force a restore (resets GetPaused() maybe?)
endif

while state  
    print("Pause")
    sync()
endwhile
Posted: 4th Sep 2024 1:59
in that example it will lead to an infinite loop:
while state
print("Pause")
sync()
endwhile
Posted: 9th Sep 2024 23:58
Well obviously you have to put the if statements and pause loop inside the main loop so "state" can be set accordingly and I did say "untested", I typed it in the browser and don't have AppGameKit installed .... just spitting ideas!
Posted: 4th Oct 2024 14:36
Yep, and I have something like the working version of that in there. AFAIK, it doesn't help.

I've since found that many games have alt-tab issues:
https://www.google.com/search?q=alt+tab+cause+loss+of+input+reddit

Doesn't really help, but at least it's not just me.
Posted: 10th Oct 2024 15:56
On WIndows 10, for AppGameKit Studio on Vulkan renderer, if the game is minimized, the game will run without FPS limit and consume around 20% higher CPU compared to when the windows is on. The loop is still running, only it's running very very fast.
Also, another thing that happens is, one AppGameKit user reported that if a screen recording program is started (rendering the AppGameKit game out of focus), the recording result will show that the game is running very very fast without FPS limitation. This is solved by using 'Basic' as renderer.
Furthermore, any 3D objects, PRINTS, or texts created during the minimized state, will be garbled up, or straight up doesn't show. 3D models will have its polygons strewn across the whole scene, like it has exploded.
Keyboard scancode detection is also messed up. If the game is minimized while a key is pressed, the game will continue to detect the key as if it's still being pressed, and even after the windows is being maximized again, the game still detect the key as being pressed. I need to re-press the exact same key to 'reset' it. Pressing other keys won't reset it.
If left minimized for extended period of time, the game will freeze and crash, and cannot be resumed anymore.

As IBOL said, GetPaused() will return 1 only at the very frame when the windows is minimized. After that frame, during minimized state, or even after the program is maximized again, it will return 0.
There are no functions to detect whether the program is back on focus, or being maximized. I detect the program 'resume' by detecting pointer movement and keyboard click.
I've partly mitigate this problem by putting every new 3D object/text creation on hold during minimized state.

On Classic, I haven't encountered these problems.