#WorkerThreadPool not executing tasks until waited for

1 messages · Page 1 of 1 (latest)

cerulean owl
#

I've got a game I'm working on that exhibits this problem in the web build but not in the editor or native builds, and I've tried to make a minimal repro case but haven't been able to get it to have the same problem, even on web builds.

The game loads assets like card portrait art for community-created game modes over HTTP and stores them locally in a cache. The HTTP request works fine, but the initial check for whether the asset is already cached and the decoding of the HTTP response are supposed to happen in worker threads. In most cases, this works as expected, with the worker task queue very quickly being emptied out and no game performance hit.

However, on the web build, the tasks in the worker task queue do not begin to be executed at all until they are explicitly waited for, meaning even a very simple game mode with only a few custom portraits that are all already cached will require a loading screen that waits on the main thread for the task queue.

I'm looking for help either getting the task queue to start tasks without an explicit wait or figuring out how to reproduce this in a simpler project so I can submit a bug report.

https://git.lubar.me/ben/spy-cards/src/commit/19a3f90fc00ef4ef489f58274fe5d4f5650c5390/godot/api/file_requester.gd#L37-L66

demo is at https://spy-cards.lubar.me/godot/

#

strangely, the worker task queue does seem to execute to some extent in chrome, but nowhere near as fast as I'd expect it to on a 24 core machine. in firefox, it doesn't move at all until waited for.

cerulean owl
#

ah, I think I figured it out. threading/worker_pool/max_threads claims that it's the maximum and that -1 means "no limit" but in reality it's the actual number and -1 means "engine default for this platform"

on every platform but web, it's the number of processor cores, but on web it's hard-coded to 1 for some reason even though the number of cores is available to godot and gets read elsewhere