Chrome hangs after certain amount of data transfered - waiting for available socket

前端 未结 6 2081
抹茶落季
抹茶落季 2020-11-28 19:41

I\'ve got a browser game and I have recently started adding audio to the game.

Chrome does not load the whole page and gets stuck at \"91 requests | 8.1 MB tr

6条回答
  •  独厮守ぢ
    2020-11-28 20:30

    Explanation:

    This problem occurs because Chrome allows up to 6 open connections by default. So if you're streaming multiple media files simultaneously from 6 or tags, the 7th connection (for example, an image) will just hang, until one of the sockets opens up. Usually, an open connection will close after 5 minutes of inactivity, and that's why you're seeing your .pngs finally loading at that point.

    Solution 1:

    You can avoid this by minimizing the number of media tags that keep an open connection. And if you need to have more than 6, make sure that you load them last, or that they don't have attributes like preload="auto".

    Solution 2:

    If you're trying to use multiple sound effects for a web game, you could use the Web Audio API. Or to simplify things, just use a library like SoundJS, which is a great tool for playing a large amount of sound effects / music tracks simultaneously.

    Solution 3: Force-open Sockets (Not recommended)

    If you must, you can force-open the sockets in your browser (In Chrome only):

    1. Go to the address bar and type chrome://net-internals.
    2. Select Sockets from the menu.
    3. Click on the Flush socket pools button.

    This solution is not recommended because you shouldn't expect your visitors to follow these instructions to be able to view your site.

提交回复
热议问题