• 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
0
Question by misun1191 · Aug 22, 2020 at 01:25 PM · fpswebgltime.time

webgl, Unity time and system time mismatch with low FPS

Hi, I made a simple spatial memory experiment (player walk around the scene and remember the location of props. I analysed their memory error for my scientific research ) using Unity 2019.1. I built WebGL, posted on my webserver and recruited players (=experiment participants) from Mechanical Turks. The problem is that at least 15% of players experienced a laggy behaviour (low frame rate) and there is a huge mismatch between the Unity internal time and System time.

For instance, Unity.Time showed that 300 sec has passed between the events, but System.DateTime.Now indicated that 600~2000 sec has passed between the events. This problem occurred in only some players and I have no idea why or how this happened. I noticed that when this discrepancy happened, frame rate was low as 10FPS. Most other players had a decent FPS (50 or higher) and Unity Time and System Time match. I don't know what kind of system, browsers were used by players who experienced the laggy behaviour. I only have one anecdote from anonymous player that initial loading of the WebGL was fine, but the movement was very slow.

  1. Does anyone experience a similar problem?

  2. Why is there a discrepancy between the Unity Time and System Time? (there is no Time.scale/pause used in my game, so I think the two should be almost perfectly in line)

  3. Is there any recommended practice/procedure that only allows users with reasonable computing facility to play the game?



any comments, help would be greatly appreciated! Thanks

Misun


Additional information about how I recorded the player's position in while loop (like below).

 IEnumerator familiarPhase(){
    string savefn=subId+"_familiarisation_"+System.DateTime.Now.ToString("yyyyMMdd_HHmm")+".txt";
    string savetext="";
 
    float inittime=Time.time; float timelimit=300;
    while (Time.time-inittime<timelimit){
       savetext=savetext+Time.time.ToString("F2")+"/t"+character.transform.position+"/n";
       yield return null;
    }
    StartCoroutine(save2file(savefn,savetext)); //custom made function that save the string into file on the web server (using Unity SendWebrequest)  }
 

I included System.Time information in the file name to know when the player started this part of the game. I then saved Unity internal time (Time.time). In my experiment(=game), multiple small tasks are executed in order.

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 misun1191 · Aug 22, 2020 at 01:30 PM 0
Share

Probably the most relevant looking thread is this one by @homer_3 , who experienced low FPS and mismatch in timing when playing audio. I don't think the solution suggested to this other thread is relevant to my problem..

https://answers.unity.com/questions/1208212/time-not-accurate.html?sort=votes

avatar image N-8-D-e-v · Aug 27, 2020 at 01:57 PM 0
Share

System.dateTime.now is always the most accurate if I remember correctly, and Unity.time doesn't exist as far as I know, unless you mean Time.time. Of course, your issue could just be with webgl, have you tested on a standalone build?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by misun1191 · Dec 16, 2020 at 06:32 AM

I now realised the reason for the mismatch between Unity Time and SystemTime in WebGL. If players defocus the WebGL browser (e.g. click other browser tab), then Unity clock is paused while System Time is still updating. So, the timing issue was independent of frame rate.

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

182 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 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

Disable VSync in WebGL build 0 Answers

How do I make my WebGL game to run smoother? 0 Answers

FPS = 440 according to Stats, but Update prints only 50 frames? 1 Answer

GameObject Instanitation causing lag on webgl for mac os with chrome 0 Answers

WebGL low fps 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges