Skip to content

Conversation

@KyuubiDDragon
Copy link

Hello, i fixed the tile loading and tested it for me.

There you can see how fast it is for me.

https://www.dropbox.com/scl/fi/3qu6ohngyqkfsim2lrorr/brave_NOS0VhXcF1.mp4?rlkey=0ymo6web2eei1qm0nqidm33ms&raw=1

The main issue was that getBaseTileWithPixels() didn't check the disk cache
before regenerating tiles. This meant that even when base tiles were cached
on disk, composite tile generation would regenerate all 256 base tiles.

Changes:
- Add disk cache check to getBaseTileWithPixels() with PNG-to-pixel decoding
- Create PngDecoder class to decode PNG bytes back to pixel arrays
- Increase MAX_PIXEL_CACHE from 512 to 2048 (prevents cache thrashing)
- Increase MAX_CONCURRENT_GENERATIONS from 4 to 16 (faster parallel generation)

This significantly improves performance when zooming out, as cached tiles
can now be reused for composite tile generation instead of regenerating.
- Add zoom event handlers to pause batching while zooming
- Cancel pending/in-flight requests when zoom starts (AbortController)
- Use adaptive batch delay: 150ms at zoom >= 0, 400ms at negative zoom
- Don't schedule new batches during active zoom
- Small delay (100ms) after zoom ends before resuming batch collection

This prevents the cascade of batch requests when rapidly zooming,
especially at negative zoom levels where composite tiles are expensive.
Frontend:
- Reduce minNativeZoom from -4 to -3 (64 base tiles instead of 256 = 4x faster)
- Users can still zoom out to -4, tiles are scaled from -3

Server:
- Increase DiskIO thread pool from 2 to 6 for faster parallel reads
- Add early bail-out for unexplored areas in composite tile generation
- New hasAnyExploredChunks() method samples corners/center first for speed
- Skip fetching 64 base tiles if area is completely unexplored
@cryptobench
Copy link
Owner

Thank you for you contribution. I'm merging your PR. 👍

@cryptobench cryptobench merged commit b442db7 into cryptobench:main Jan 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants