owl-project / NVISII

Apache License 2.0
319 stars 27 forks source link

Application halts prematurely when clearing scene and changing skybox too quickly #150

Open kevinfoley opened 2 years ago

kevinfoley commented 2 years ago

If nvisii.clear_all() and nvisii.set_dome_light_texture() are called too close together, the application will prematurely terminate.

Simple test case:

import nvisii
from nvisii import texture
import time

nvisii.initialize(headless=False, verbose=True)

while True:
    print('clearing...')
    nvisii.clear_all()
    print('loading skybox...')
    tex : texture = texture.create_from_file('Skybox', 'skybox.jpg')
    nvisii.set_dome_light_texture(tex, True)
    time.sleep(.01)

The output from the while loop should keep repeating forever, but in reality, the loop will run a couple of times and then the application will terminate:

clearing...
loading skybox...
clearing...
loading skybox...
Press any key to continue . . .
natevm commented 2 years ago

This is likely a race condition somewhere...

A possible workaround might be to use nvisii.disable_updates() until the loop completes, then call nvisii.enable_updates() at the end.

In the meantime, I'll mark this as a bug to fix on the todo list.