Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question What is the best practise for WebGL build updates?

Discussion in 'Web' started by manuelgoellnitz, Nov 2, 2022.

  1. manuelgoellnitz

    manuelgoellnitz

    Joined:
    Feb 15, 2017
    Posts:
    397
    When a user has loaded your WebGL game, and you publish a new version of it. Is there a best practise to notify the user, that he should reload the page, because the client was updated?

    When the game has no dependencies, that is not a problem. But we have for example addressables which are probably changed by the update so the old client is no longer working properly.
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,511
    I'm assuming it's a multiplayer experience with WebGL clients and a dedicated server somewhere? If so you should implement all the shenanigans of online multiplayer games for smooth updates:

    • display some kind of permanent notification with a countdown timer in the game that says something like "scheduled server maintenance" - leave enough time for players to finish the game
      • ideally prevent new clients from joining games within a time period before the scheduled maintenance
    • try to make sure clients finish gracefully when or before server goes down (or is about to go down for scheduled maintenance)
    • implement a versioning of both clients and server
    • every breaking server update bumps the version
    • while server is offline
      • launch the "maintenance" server
      • publish the new client build
      • publish the new server build
      • restart server instance and check if everything works as planned
      • shutdown maintenance server
      • start normal server
      • (all of this may require fiddling with network settings too, like redirecting connection request via port forwarding)
    • if client version is less than server version, disallow connection and pop up a message instructing client to reload browser page
    • if server is down for maintenance, client attempts to make a connection will be with the maintenance server - its only purpose is to let clients know about the maintenance so they see a message, and the maintenance server disconnects the client after sending that message
    That's should cover most of it.

    If it's a singleplayer game I would simply publish it to a versioned folder, and update all non-versioned incoming links to point to the latest version, usually using forwarding techniques. That way users of older versions can keep playing indefinitely with their current version, provided the game isn't using any of the non-versioned URLs to access data.