Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After build comes out When the program loses focus and runs for a while, the program will not respond #14

Open
haojisama opened this issue Mar 6, 2020 · 7 comments

Comments

@haojisama
Copy link

After build comes out
When the program loses focus and runs for a while, the program will not respond
But the program is still running

use unity2019.3.3f1

@mrayy
Copy link
Owner

mrayy commented Mar 7, 2020

Can you confirm that Player Settings --> Resolution and Presentation --> "Run in Background" is checked on?

@haojisama
Copy link
Author

Yes, is checked on

@haojisama
Copy link
Author

Full screen seems to solve this problem. I don't know why? Is it about resolution?

@3DI70R
Copy link

3DI70R commented Mar 13, 2020

Actually, i have same problem.
I use windowed mode, since im creating application which displays interactive stuff into OBS and ability to minimize it is very important for me.

Window works fine when minimized, but when you're trying to maximize it, window appears to be frozen (spinning circle, "(not responding)" in window title). You can see that your application is working, but you cannot interact with it anymore.

Some interesting details that i've found while trying to pinpoint the issue:

  • This problem was introduced in 2019.1, 2018.4 has no issues
  • Using "Exclusive Fullscreen" fixes this issue (but this is not acceptable for me)
  • Window freezes even if you send textures not every frame (once in every 10 frames, for example)
  • UnityCapture, fork by schellingb has same issue

I hope this information was useful.

@guiglass
Copy link

guiglass commented Mar 14, 2020

Same problem. Exactly 5 seconds after loses focus and wham - application crash..

but the stream in OBS continues to play fine and my game still working. It's just that the window is frozen and Windows asks me to end task. And has become completely unrecoverable.

--

I am using Unity 2019.3.2f1 and Windows 10.

It does not freeze if the window is minimized
It does not freeze if the window is in focus
It does not freeze if the window repeatedly focused and unfocused

maximizing window and it still freezes.

I have not tried full screen - but I fullscreen is not compatible with my game and I must use windowed.

Can you please help me find where the issue is?

@3DI70R
Copy link

3DI70R commented Mar 22, 2020

So, i think i found a solution for 2019.1+. Let me know if this works for all of you too.

This method from Win32 api removes indication that window is not responding. Although this seems like just visual fix, input and other things work fine for me when i return to the window.

Just call WindowsUtils.DisableWindowGhosting() somewhere during initialization.

public static class WindowsUtils
{
    [DllImport("user32.dll")]  
    private static extern void DisableProcessWindowsGhosting();

    public static void DisableWindowGhosting()
    {
        if (!Application.isEditor)
        {
            DisableProcessWindowsGhosting();
        }
    }
}

@mrayy
Copy link
Owner

mrayy commented Mar 24, 2020

  • Tested on Unity 2019.2.13f1 and it has no issues both in Editor and after Build.
  • Tested on Unity 2019.3.6f1, there was a problem at the build but not related to the lost focus issue, it was related to loading a shader at runtime. The lost focus issue didn't occur on my machine.

Tested on Windows 10 Version 1903.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants