Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
1
Question by Chris Sinclair · Jul 20, 2012 at 08:06 PM · performancewebplayerframerateslowdown

Low Application.targetFrameRate slows Silverlight/Browser too

Been developing an application which uses both Silverlight and Unity side-by-side in the web browser. However, we've found that when Unity is performing a lot of work (either due to complex scenes, underpowered hardware, etc) it was negatively impacting the performance of Silverlight to the point of no longer being usable.

We tried having Unity "idle" when not being directly interacted with by the user by dropping its frame rate using Application.targetFrameRate. Initially, it works great and the Silverlight performance shoots back up through the roof. However, the performance degrades to the point where Silverlight starts running at the same framerate as Unity. It also seems to affect the browser overall (closing the window, interacting with it can become delayed).

I've profiled the processing of Silverlight, and considering the browser slowdown, I think the main browser process might not be triggering the main Silverlight runtime's loop. Once the loop executes, the code processes as quickly as ever, but the browser/runtime just waits and waits until Unity runs its update for its next frame. As soon as we set the Application.targetFrameRate back up to 60fps, everything works fine again (albeit with the degraded performance we were trying to solve in the first place)

I put together a sample test that demonstrates this. Simply on the left-hand side in Silverlight, a smiley face follows the mouse cursor and on the right-hand side Unity displays a spinning cube. If you click the "Drop Frame Rate to 2 FPS" button in Unity, then continually move your mouse around in Silverlight, after about 10 seconds or so, you'll notice that the smiley face starts pausing instead of smoothly following your mouse. The performance continues to degrade until the smiley face updates are synchronized with Unity's frame rate (and even worse sometimes if it skips a frame). Click the "Increase Frame Rate to 60 FPS" will fix the performance, and clicking the 2 FPS button after will go through the same process of slowly degrading performance.

You can access the test here: http://sketcher.genexissystems.com/UnityFrameTest/

The only Silverlight code is:

 public MainPage()
 {
     InitializeComponent();
 
     MouseMove += MainPage_MouseMove;
 }
 
 private void MainPage_MouseMove(object sender, MouseEventArgs e)
 {
     var position = e.GetPosition(this);
     this.image1.Margin = new Thickness(position.X - image1.Width / 2, position.Y - image1.Height / 2, 0, 0);
 }

And on Unity's side, the only pertinent code is:

 public class ChangeFrameRate : MonoBehaviour
 {
     private void Start()
     {
         QualitySettings.vSyncCount = 0;
         Application.runInBackground = true;
     }
 
     private void OnGUI()
     {
         if (GUI.Button(new Rect(0, 0, 250, 20), "Drop Frame Rate to 2 FPS"))
             Application.targetFrameRate = 2;
 
         if (GUI.Button(new Rect(0, 30, 250, 20), "Increase Frame Rate to 60 FPS"))
             Application.targetFrameRate = 60;
     }
 }

So far we've tested and duplicated the slowdown on Windows XP and Windows 7 running on IE 8/9, Firefox 13/14, and Google Chrome 17/20. We've also found that the time needed to exhibit the slowdown can vary from operating system and browser though we have found that generally, Chrome takes the longest to slowdown and IE degrades the fastest.

This is created with Unity Pro 3.5.2f2.

Any thoughts or insights on this, or possible solutions would be greatly appreciated! Thank you!

EDIT: By the way, CPU usage during the tests never rose above 2% so this isn't an issue with one of them hogging the CPU, just thread waiting I guess.

Comment
Add comment · Show 2
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
avatar image whydoidoit · Jul 20, 2012 at 09:35 PM 1
Share

FYI doesn't happen on my $$anonymous$$ac running Chrome.

avatar image Chris Sinclair · Jul 20, 2012 at 09:37 PM 0
Share

@whydoidoit thanks for the mac test; good to hear!

0 Replies

· Add your reply
  • Sort: 

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity RTS/FPS Optimization 1 Answer

Web player stalls 1 Answer

Rendering overhead on Android 0 Answers

Performance difference between webPlayer and Flash? 0 Answers

Animations causing big Performance Drop 1 Answer


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