Fitting M87*’s gas into a browser download
· By Stef
The moving gas round M87* on this site is now a 1.68 MB download. Played straight from the simulation it comes from, the same gas would need about 50 MB a second.
M87* is the black hole at the centre of the galaxy M87, the first black hole photographed (by the Event Horizon Telescope, in 2019). The site's earlier article on it is Inside M87*.
Getting there took four steps.
Where the gas comes from
The gas is from a GRMHD simulation made by astronomers at the University of Illinois and published as open data. GRMHD is general relativistic magnetohydrodynamics: the equations for magnetised gas moving in the curved space round a black hole.
The simulation is saved as snapshots, each one moment of the gas. Snapshots are 5 M apart on the simulation's clock, where M is a length and time set by the hole's mass. For M87*, one M of time is about nine hours, so 5 M is about two days.
The site draws the light the gas gives off at 230 GHz, the radio frequency the Event Horizon Telescope observes at.
The problem: size
One snapshot, cut down to the part the site needs, is about 42 MB. The site plays the gas at 6 M a second close to the hole, so real snapshots would mean about 50 MB a second.
A short loop is no better. 24 real snapshots stored as video came to 56 MB, and they repeat every 115 M.
Step 1: gas made from statistics (18 November)
The idea was to make gas that looks like the simulation from the patterns in its data, without needing the data itself. So we measured the simulation's density, temperature and magnetic field:
- the average at each place
- how much each varies, and how they vary together
- how big the patterns are, and how fast they fade and renew
The generator, the code on the page that makes the gas, then shapes random noise to match those numbers.
The three quantities have to vary together, because dense gas is cooler and less magnetised. Noise in which the three vary together as measured gives the simulation's total light to within 6%. Noise where the three vary separately gives 1.7 times too much light.
The file was 8.2 MB. The tables of statistics were 43 KB of that, and the rest was four blocks of stored random noise, each 128 x 128 x 128 values.
The gas never repeated and its light was right. Its shapes were not: soft clouds where the simulation shows thin sheets and threads.
Step 2: real snapshots as the patterns (28 to 30 November)
In place of some of the noise, the generator now reads four real snapshots. Density, temperature and field are read from the same place, so a sheet in one lines up with the sheet in the others.
Each snapshot keeps only the part that gives over 99.7% of the light: out to about 23 M from the hole, close to the flat plane the gas swirls round in.
The generator takes patches of pattern from the snapshots and carries each patch round the hole. Every so often an old patch fades out while a fresh one, from another place or snapshot, fades in. That is why the gas still never repeats.
The file grew to 27.7 MB, and the gas still looked like fluffy clouds. That was wrong. A black hole shreds anything with shape into long thin lines, and the simulation shows exactly that.
The cause was the direction of the magnetic field. The radio light depends on the angle between the line of sight and the field. In the simulation the field is combed round the hole, along the flow, so the light runs in long lines.
The generated field leaned out and up at random, which broke the light into round patches. Now, inside the region where the real patterns are used, the field runs round the orbit.
A "stretch" score says how many times longer than wide the bright patterns are. Seen from 25 and 5 degrees above the disc:
- The simulation: 3.20 and 3.32
- Before the fix: 2.77 and 2.62
- After: 2.98 and 3.24
Snapping. On screen, bits of the gas jumped suddenly from one frame to the next. To count it, we cut the picture into small squares and called it a snap when a square changed by more than four times its usual amount in one frame.
The simulation gave 4.0 snaps for every 1,000 squares in a frame, and the generated gas 8.0. The snaps came as an old patch handed over to a new one. Making that hand-over gentler brought it to 4.1.
The total radio light still matches. The generated gas gives 0.987 janskys, the unit radio astronomers measure brightness in, against 0.982 for the simulation's own gas drawn the same way. On 30 November this version became the Detailed gas, the simulation gas you can choose on M87*'s page.
Step 3: the noise becomes a recipe (30 November)
Ordinary compression barely helps, because random noise does not compress. gzip, the standard compression on the web, takes the 27.7 MB file only to 23.0 MB.
But the noise blocks were always made from a recipe:
- one starting number, the seed
- seven numbers per block, saying how strong the pattern is at each size and which way it is stretched
- one standard maths step, an inverse Fourier transform, that turns those numbers into noise
So the file now carries the recipe, and the page grows the noise itself after the download, in the background. In Chrome that takes about 1.6 seconds and matches the stored noise exactly: 0 of 8,388,608 values differ.
I haven't checked Safari or Firefox yet, where the maths could round a rare value differently.
The file went from 27.7 MB to 18.4 MB.
Step 4: the snapshots as video (30 November)
The four snapshots were now almost all of the 18.4 MB. So we store them as a video in the AV1 format, one frame for each distance from the hole. Video is good at this, because each frame looks a lot like the one before.
The file went from 18.4 MB to 1.68 MB. The video is 1.29 MB of that.
Video is not exact. On the 0 to 255 scale each stored value uses, the average value is off by 1 to 2. The worst single value is off by 68, at a sharp edge.
That does not show in the picture. Drawn from the video, the gas's stretch and brightness are within 2% of the 18.4 MB file. So is how much its edges run in lines, from three different views.
The browser plays the video with its own decoder. In Chrome it unpacks all 128 frames in about 0.1 seconds, to exactly the same values as the encoder's own decoder gives.
Who sees it
The simulation gas is the "Detailed gas" option on M87*'s page. It needs WebGPU, the newer graphics system browsers offer, and on desktops that have it the option is on by default.
A browser that cannot play AV1 video gets the 18.4 MB file instead.
Phones start with the site's usual gas: the glowing disc drawn on every page, easy for any device.
Not built yet
The step 1 gas, made from statistics alone, would be about 0.3 MB with the recipe. Its shapes are softer, but it would be a very small download.
Whether the 1.68 MB gas would run well on a phone is not tested. The download is one thing. Whether a phone's graphics chip can draw it fast enough is another.
Credit
The simulation is by Dhruv and others (2025), from the Illinois GRMHD library, open data under CC BY 4.0. Measurements are by the site's own scripts, 18 to 30 November 2026.