basliberty.blogg.se

Chrome force refresh css random number
Chrome force refresh css random number










While we’re here, we can lean on JS features to provide a better usability than typical random libs provide for this use-case.

CHROME FORCE REFRESH CSS RANDOM NUMBER GENERATOR

It would be much better to provide the ability to manually seed a generator and get a predictable sequence out. Simple PRNGS like an LCG aren’t hard to code, but they don’t produce good pseudo-random numbers better PRNGs are harder to implement correctly. Games that use randomness and want to avoid “save-scumming”, where players save and repeatedly reload the game until an event comes out the way they want.Ĭurrently, the only way to achieve these goals is to implement your own PRNG by hand in JS. Testing frameworks that utilize randomness for some purpose, and want to be able to use the same pseudo-random numbers on both local and CI, and to be able to reproduce a given interesting test run. (You can see this in effect if you zoom the page in or out, as each change repaints the element and re-invokes the callback.) There’s no way for the callback to store state for itself (by design), so it can’t just pre-generate a list of random numbers and re-use them instead, it currently just produces a totally fresh set of borders. This demo uses Math.random() to unpredictably shift the “rough borders”, but the Houdini Custom Paint API re-invokes the callback any time the element needs to be “repainted” - whenever it changes size, or is off-screen for a bit, or just generally whenever (UAs are given substantial leeway in this regard).

chrome force refresh css random number

New APIs like the CSS Custom Paint, which can’t store state but can be invoked arbitrarily often, want to be able to produce the same set of pseudo-random numbers each time they’re invoked.ĭemo: (currently needs Chrome with the Experimental Web Platform Features flag).

chrome force refresh css random number

However, there are several use-cases that want a reproducible set of random values, and so want to be able to seed the random generator themselves. JS’s PRNG methods ( Math.random(), crypto.getRandomValues(), etc) are all “automatically seeded” - each invocation produces a fresh unpredictable random number, not reproducible across runs or realms.

chrome force refresh css random number

Proposal-seeded-random Seeded Pseudo-Random Numbers










Chrome force refresh css random number