Revolutionary-Games / Thrive

The main repository for the development of the evolution game Thrive.
https://revolutionarygamesstudio.com/
Other
2.86k stars 508 forks source link

Create a photostudio priority system #5546

Closed dligr closed 1 month ago

dligr commented 1 month ago

Brief Description of What This PR Does

Changes photostudio's task queue to be a priority queue and adds priorities to image photographing tasks.

Currently, the priorities are in that order: Tooltips > Early multicellular billboards > Cell preview buttons in the auto-evo report

Related Issues

Closes #5526

Progress Checklist

Note: before starting this checklist the PR should be marked as non-draft.

Before merging all CI jobs should finish on this PR without errors, if there are automatically detected style issues they should be fixed by the PR author. Merging must follow our styleguide.

hhyyrylainen commented 1 month ago

The code looks fine to me (other than that one unnecessary zero initializer that the CI caught). I'll test this in-game later if no one else can do that.

CI09 commented 1 month ago

When I switched from auto-evo tab to timeline tab, the square in which cell preview is shown loaded didn't finish loading before timeline tab preview, is this expected? Sorry if I'm not clear but I'm not sure how to explain it.

dligr commented 1 month ago

When I switched from auto-evo tab to timeline tab, the square in which cell preview is shown loaded didn't finish loading before timeline tab preview, is this expected? Sorry if I'm not clear but I'm not sure how to explain it.

If you mean that the species buttons in auto-evo report don't load before the timeline tab loads, then yes, this is the expected behavior. This PR is intended to make some species previews load faster (with more priority) than some other species previews. For example, species tooltips should now load faster than species preview buttons in the auto-evo report.

HexapodPhilosopher commented 1 month ago

This seems to completely eliminate the issues I was having. The multicell cell type preview images mostly load quickly, and the ones that don't load quickly are all loaded in less that 30 seconds. No permanent lockups to the images loading. I am still getting continual error messages, though. It's this one over and over: void CellHexesPhotoBuilder.BuildHexStruct(): System.InvalidOperationException: Species is not initialized

hhyyrylainen commented 1 month ago

I'm not 100% sure, but I'm pretty sure this causes boxing:

kuva

So I need to veto the current implementation because it can cause up to 100 extra object allocations per generated image increasing garbage collector pressure, which means that the new implementation is worse than before.

Is it possible to pass a custom comparer that wouldn't take in a nullable reference to the tuple? That way the comparison operation wouldn't need to box the arguments.

dligr commented 1 month ago

Is it possible to pass a custom comparer that wouldn't take in a nullable reference to the tuple? That way the comparison operation wouldn't need to box the arguments.

Seems to be possible (documentation). And since the priority is non-nullable, there wouldn't be boxing here in case of a non-generic implementation.

hhyyrylainen commented 1 month ago

@HexapodPhilosopher

Still no one else has been able to trigger:

void CellHexesPhotoBuilder.BuildHexStruct(): System.InvalidOperationException: Species is not initialized

So I think it is either really rare on everyone else's computer or something is wrong for you locally causing it. If you can find some way to consistently trigger it on someone else's computer I can then try to find out what goes wrong (it might be related to things taking really long to generate on your system so maybe something is deleting / reusing the species object before it is photographed or something like that).