Inspiration

WebGL has become popular rapidly: 53% of top-100 websites now use WebGL [Yao et al. 2018]. WebGL provide online 3D supports comparable to local games, but unfortunately, online 3D games is rare because file transfer from server to browser is slow. The Inter-Planetary File System (IPFS) is a peer-to-peer protocol designed to store file in blockchain in a decentralized manner. In this project, we explore the possibility of using IPFS to accelerate WebGL games.

What it does

diagram In this diagram, we show how our project works. On the left, a traditional WebGL program downloads both the WebGL page and WebGL data (e.g., shaders, textures) from a remote server. The download speed is limited to the connection bandwidth. On the right, we redirect the WebGL data to IPFS. IPFS serves the data directly to the browser.

How we built it

As a proof-of-concept, we set up a local IPFS on a local machine. On another local machine, we run a modified Unity WebGL engine. The modified engine will instruct the browser to obtain data files from IPFS. For full steps, please refer to our GitHub page.

Challenges we ran into

We overcome several challenges while setting up IPFS to serve WebGL objects, and modifying the WebGL loader. We manage to change the Unity WebGL loader javascript to allow for absolute URL to our local IPFS gateway.

Accomplishments that we're proud of

benchmark We show the IPFS-accelerated WebGL loading is much faster than retrieving the WebGL data files from a remote server. In the experiment, we setup the IPFS local host and WebGL host on one machine, and launch Chrome browser on another machine connected to the same LAN network.

The DOM content loading time for the baseline WebGL is 459 ms, and for the IPFS-accelerated is 137 ms. IPFS-acceleration DOM loading is 4.81x faster. Overall, the webpage loading time for the baseline WebGL is 2510 ms, and for the IPFS-accelerated is 597 ms. The overall speed is 4.2x faster.

What we learned

Interestingly, Chrome browser won’t fully download IPFS-accelerated WebGL data files, but it does fully download the baseline WebGL data files. In the net profile, the downloaded size is 650 KB for IPFS, and 7.4 MB for the baseline. It benefits us because our IPFS-accelerated page downloads less data. But how can it be? WebGL data are XHR files that are dynamically loaded behind the scene. It is possibly because IPFS is fast enough for the browser to load it on the fly. But for remotely hosted WebGL content, Chrome loads them before launching WebGL.

What's next for IPFS WebGL Gaming

The next step is to make the IPFS redirection as a Chrome plugin, so that our system will work on any WebGL pages. Currently, our modifications to the Unity engine only allows us to redirect Unity-based WebGL games.

Share this project:

Updates