Fix: Cycles crash when stats are enabled and render is cancelled

The crash happens when the Blender is launched with the Cycles
statistics printing enabled (`-- --cycles-print-stat` command line
arguments) and the render is cancelled during synchronization phase.

It is not super clear how exactly statistics should be presented in
such case. Currently it will make is kernel times are there and are
set to 0, and object/shader statistics is not shown at all.

Pull Request: https://projects.blender.org/blender/blender/pulls/155179
This commit is contained in:
Sergey Sharybin 2026-03-04 15:57:30 +01:00 • committed by Sergey Sharybin
parent 87ab53e848
commit 1eabe1baaa

View file

@ -133,12 +133,22 @@ void Profiler::remove_state(ProfilingState *state)
uint64_t Profiler::get_event(ProfilingEvent event)
{
assert(worker == nullptr);
if (event_samples.empty()) {
return 0;
}
assert(event_samples.size() > event);
return event_samples[event];
}
bool Profiler::get_shader(const int shader, uint64_t &samples, uint64_t &hits)
{
assert(worker == nullptr);
if (shader_samples.empty()) {
samples = 0;
hits = 0;
return false;
}
assert(shader_samples.size() > shader);
if (shader_samples[shader] == 0) {
return false;
}
@ -150,6 +160,12 @@ bool Profiler::get_shader(const int shader, uint64_t &samples, uint64_t &hits)
bool Profiler::get_object(const int object, uint64_t &samples, uint64_t &hits)
{
assert(worker == nullptr);
if (object_samples.empty()) {
samples = 0;
hits = 0;
return false;
}
assert(object_samples.size() > object);
if (object_samples[object] == 0) {
return false;
}