Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by cgrip · Jul 19, 2018 at 04:33 PM · renderingrenderwindows 10focuswindowed

Unity2018.2 : Gfx.WaitForPresent() causes rendering to freeze when (Windows10) app looses focus

I just noticed a strange rendering behavior that seems new to Unity2018.2.0f2 (was previously using Unity 2017).

On a Windows PC (mine is running Windows10), when running a Unity app in windowed mode, the rendering/presenting will freeze if the app looses focus to another window and the mouse is not moved for more than 7 seconds. Scripts will still poll fine and audio works fine, too. Rendering will resume as soon as the user moves the mouse again.

This does not happen when running from inside the Unity Editor, just when running the packaged Unity app. Unfortunately, this also does not seem to happen when the Debugger is attached.

Looking at the Unity Profiler there is a stall at Gfx.WaitForPresent() until the mouse is moved again and rendering resumes.

I've narrowed this bug down to the use of GL.IssuePluginEvent(). The native function that it calls is doing nothing and simply return-ing.

If GL.IssuePluginEvent() is not called, the above bug does not happen; the app will render just fine.

Repro:

1) Make a Unity app that calls to a native C++ method using GL.IssuePluginEvent() at end of every frame

2) Run packaged Windows app (the stand alone app and not in the Editor)

3) While app is running, switch focus out of the Unity app and to another window (ex. Windows File Explorer)

4) Don't move mouse for about 7 seconds

5) The Unity player window will stop rendering and will hold on the same frame until the mouse is moved again

I'm wondering if anybody else has seen this issue with the latest Unity2018.2 and (for the Unity devs) is this a known worked on problem? I did not find any open tickets in the Issue Tracker page.

Thanks in advance, - Chris

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by cgrip · Jul 19, 2018 at 10:31 PM

An Update:

it turns out that GL.IssuePluginEvent() was not the culprit. It was Texture.GetNativeTexturePtr(). Calling Texture.GetNativeTexturePtr() on every frame will cause the above bug of making the game stop rendering/presenting new frames while the window is out of focus - until the mouse gets moved.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

93 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity Rendering 1 Answer

Custom shader renders back objects only in certain angles 1 Answer

How do I make all game objects with a certain tag appear on trigger enter? (C#) 2 Answers

URP Explenation? 1 Answer

Window title bar 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges