UEngine::OnLostFocusPause is never called

UEngine::OnLostFocusPause is never getting called which means, in turn, AHUD::OnLostFocusPause is never called. We’d like to know when the game has lost focus so we can stop the game from running in the background.

We had tried to work around this using FViewport::IsForegroundWindow() but

  1. Polling is (in this case!) worse than being event driven and
  2. This function, for us, calls FSceneViewport::IsForegroundWindow() and not FWindowsWindow::IsForegroundWindow() - and it ends up being surprisingly slow(!).

Profiling showed that almost 5% of the game thread was being spent inside FSceneViewport::IsForegroundWindow() (or functions that it calls) - more than ticking all of our (hundreds of!) actors combined!

Still, that’s getting away from the main point - that UEngine::OnLostFocusPause() isn’t ever being called leaving us with no good way (that I know about) of knowing whether we’ve lost focus - or gained it again!

Do you mean 4.3 or 4.2 in your title?

Wishing you luck with this!

Hey Rama! I mean 4.2 - though it doesn’t look like it was fixed in 4.3 either!

I’ll remove the version from the title since it’s a little misleading. :slight_smile:

And thanks!

I am wishing you luck with this!

I had no idea that FSceneViewport::IsForegroundWindow was slow!

#:heart:

Rama