Loading on the browser main thread cannot start more than the 8
pre-created workers: beyond that, thread creation waits for the main
thread to return to its event loop, which the load never does.
Decompression threads were only an optimization, so on emscripten
spawn workers for at most 4 streams and decompress the rest on the
loading thread.
Block sizes weren't checked against the file length, so truncated files
made the decompression threads read off the mapping. Validate framing
(u32 size + payload) before the mapping and threads exist; also reject
zero-stream or empty files.
This completely ignores error handling, which probably should be added.
The code behavior doesn't change, as the existing comparisons and
asserts already promoted the signed value to unsigned.
Use spin-locks for synchronization.
IsEOF() is now buggy, but the bug chance is fairly low (1/65536) - it
can happen when the last compressed block has exactly max decompressed
block size. Don't care about it much, as it's only used to open old
archives.
Tracy will now perform a number of checks when trying to read a dump
file:
1. The file must have at least 4 bytes of data.
2. There should be a 4 byte header to indicate the file was saved by
tracy. This is a breaking change in file format.
3. Old header-less files are still supported, but there's a new check
for data validity. The first 4 bytes of file (as an uint32) must be
less or equal to max LZ4 data packet size. This requires the first
two bytes to be 00 00 or 00 01, which should catch most invalid
files.