niels747 / 2D-Weather-Sandbox

Two-dimensional, realtime, interactive simulation of earth's troposphere.
https://niels747.github.io/2D-Weather-Sandbox/
GNU General Public License v3.0
81 stars 27 forks source link

Sounding graph, weather stations and save files broken on Firefox Linux. #99

Open Cloudwalk9 opened 10 months ago

Cloudwalk9 commented 10 months ago

Only the lapse rate line seems to render.

Replacing

        if (wallTextureValues[4 * y + 1] != 0) { // if this is fluid cell

with

        if (temp < 599.0) {
          // not wall

seems to fix it. This is probably not a proper fix but it's a clue what might be going wrong.

niels747 commented 10 months ago

Very interesting, I will test on a linux machine myself.

Cloudwalk9 commented 10 months ago

Just in case for repro, I'm using the nvidia proprietary driver in PRIME offloading of firefox but it also occurs with intel gfx

niels747 commented 9 months ago

I tested on Linux, didn't work on Firefox but worked fine on Chromium. What GPU do you have exactly?

Cloudwalk9 commented 9 months ago

I tested on Linux, didn't work on Firefox but worked fine on Chromium. What GPU do you have exactly?

RTX A4000 Mobile (workstation grade counterpart to mobile RTX 3070 I think) and Intel iGPU in PRIME/Optimus configuration. Nvidia 535 driver.

Chromium browsers have issues using the Nvidia GPU in PRIME offload and I got it to work only once but don't exactly know what I did to force it before resetting everything due to other issues, so I'm basically stuck with Firefox.

Cloudwalk9 commented 8 months ago

The problem lies further up in the code. It would seem that wallTextureValues is not getting populated on Firefox, and it's full of 0s. This is not the case on Chromium. So this condition is always false.

Cloudwalk9 commented 8 months ago

Found this little nugget. WebGL warning: readPixels: Format and type RGBA_INTEGER/<enum 0x1400> incompatible with this RGBA8I attachment. This framebuffer requires either RGBA_INTEGER/INT or getParameter(IMPLEMENTATION_COLOR_READ_FORMAT/_TYPE) RGBA_INTEGER/INT.

For some reason this fixes it. It probably blows up memory usage.

gl.readBuffer(gl.COLOR_ATTACHMENT2);
var wallTextureValues = new Int32Array(4 * sim_res_y);
gl.readPixels(simXpos, 0, 1, sim_res_y, gl.RGBA_INTEGER, gl.INT, wallTextureValues); // read a vertical column of cells

Using Int32Array and gl.INT where ever wallTextureValues is populated fixes both this issue, and the unreported issue of weather stations not working on Firefox. No side effects on Chrome.

Why? I don't know.

niels747 commented 6 months ago

I finally got to testing it on Linux Firefox. Indeed the fix you suggested fixes the sounding graph. I will commit it now. Those few bytes of extra memory dont matter. However there seem to be a few more problems using Firefox on Linux:

Do you experience these same problems?

I want it to run on as many devices as possible and will do my best to fix all this

Cloudwalk9 commented 6 months ago

Save files are definitely broken. Not exactly a black screen but it renders the sky and no terrain. I haven't tested the weather station issue, but chances are it's another Firefox-specific bug if it works on Chrome.

niels747 commented 6 months ago

Okay, I will fix all of these bugs soon. Thank you for your input!

niels747 commented 4 weeks ago

Please tell me if this is still an issue