Closed paulmelis closed 4 years ago
Related to our discussion over in #369, the main issue is that you created a world and passed it to ospRenderFrame
without committing it first. Embree scene creation is done on commit, not on construction.
Some other notes (more relevant to real apps, these may not actually produce issues in the version you posted):
ospCancel
does not synchronize with the future, thus you should use ospWait
to guarantee that the task has competedospIsReady
is functionally the same thing as ospWait
I should amend my first bullet: ospCancel
is not guaranteed to synchronize with the future...though in some implementations (i.e. MPI) it might.
the main issue is that you created a world and passed it to ospRenderFrame without committing it first
Right, so I should just always commit all new objects and I got lucky so far in cases where I wasn't setting any parameters after creating. Got it.
ospCancel does not synchronize with the future, thus you should use ospWait to guarantee that the task has competed
So what exactly does ospCancel
guarantee? That the running render has been signaled to cancel, but not that is has been canceled? That could explain the issues I'm seeing as the render thread will stay active while I was not expecting it. The comment in ospray.h
is then also a bit misleading as it says
Cancel the given task (may block calling thread)
which to me signals that the render thread will have been canceled when ospCancel
returns, as it might involve waiting for it to cancel
And would ospWait
for OSP_TASK_FINISHED
be the right event after a cancelation? Or might it not get there?
So what exactly does ospCancel guarantee? That the running render has been signaled to cancel, but not that is has been canceled?
You are correct: ospCancel
is not a status query (it returns void
, not bool
) unlike calls like ospIsReady
. This is the exact same semantic as the old return value of the progressCallback
from OSPRay v1.x used to signal frame cancellation. I think the better mental model is that cancellation is just a shortcut to get the running render task to finish before it completes, not that a frame being cancelled is an explicit state that the application should track. In other words, ospCancel
is to stop a long running frame because the application will no longer be interested in the finished result.
The comment "(may block calling thread)" came from previous MPI implementations we had over the summer that just blocked no matter what. We can certainly update the comment to be more clear!
And would ospWait for OSP_TASK_FINISHED be the right event after a cancelation? Or might it not get there?
Yes: essentially OSP_TASK_FINISHED
is our sentinel value for "everything is finished no matter what". In the future, we may add more asynchronous APIs, where OSPFuture
may be a handle to other types of async tasks (ospCommit
is what we are thinking about here)...so OSP_TASK_FINISHED
will always be the most conservative thing to sync with (and is the C++ default value on that parameter if you are not using C).
I guess we can close this one
While trying to debug #367 I hit upon a segfault triggered by
ospRenderFrame
re-using the same world and framebuffer. Maybe I'm doing something wrong, but I don't see it.Relevant address sanitizer report:
Here's the file based on ospTutorial.c: code.zip