Closed frnsys closed 2 years ago
Ok so it's not directly from hector, we do some processing.
Basically:
set_tgav
which itself calls the method world.update_tgav
, and all that does is add the world.temperature_modifier
to the provided tgav
.It seems very unlikely that world.temperature_modifier
would be NaN
(not totally sure how Rust would behave if that were the case).
The source of the NaN
could be hector itself or it could because of the parameters we're giving to it, e.g. one of the emissions values could be NaN
. I don't think that's the case though because in this screenshot the emissions themselves aren't NaN
.
So I tried running the playback from the game session this error occurred in, and hector doesn't seem to have any issues. So the NaN issue must be from the frontend, or it's from something the session playback isn't capturing.
Another report on encountering NaN temperature:
I tested on iPhone and Safari/Firefox/Chrome on my Mac. On my iPhone 8 Plus, the spinning Earth appears in black and white instead of color. Everything else looked perfect on mobile. On all platforms I'd eventually hit a point where the temperature went to NaN. It seemed to be around when emissions hit net zero??
That seems to align with the first report...something about emissions becoming negative
I think it may have to do with:
let emissions_factor = Math.min(1.0, consts.maxEmissions/state.gameState.world.emissions);
Which we use to limit how much emissions we pass to hector (it breaks if we reach extremely high amounts).
Also note that Math.min(1, NaN)
returns NaN
.
So first things first, I should check that emissions aren't 0 so we're not dividing by 0.
Second, I think what's happening here is if the emissions is negative, say -1, and max emissions is 200, then the factor becomes -200 (when it should actually be at most 1 and at minimum 0), so the emissions becomes in effect 200x greater. That's exactly the scenario that line of code was meant to prevent (i.e. sending way too large an amount of emissions to hector, which causes it to crap out).
We get the temperature from hector directly afaik, so maybe the cause is there?