mitsuba-renderer / nanogui

Minimalistic C++/Python GUI library for OpenGL, GLES2/3, Metal, and WebAssembly/WebGL
Other
1.57k stars 196 forks source link

Application cleanup question #78

Closed Tom94 closed 2 years ago

Tom94 commented 3 years ago

I noticed that on the latest version of nanogui, the Screen object (and its inheriting example applications) are never destructed. Is this intentional?

Destroying an application manually leads to a hard-crash with some reference counts dipping below zero.

For now, my workaround is to never destroy my application and to instead put all necessary cleanup into main(). But that seems a little hacky.

Related question: what is the purpose of the inc_ref and dec_ref calls in example1.cpp? Exception-related? If so, why are they not present in all other examples?

wjakob commented 3 years ago

Hi @Tom94,

indeed, there are some reference counting issues involving the Screen at the moment. It's related to a reference cycle involving the RenderPass. It's on my TODO list but may take some time to get to. I'd suggest that you use your workaround for now. -W

wjakob commented 2 years ago

FYI, this reference cycle issue is now fixed in on master. For details, see https://github.com/mitsuba-renderer/nanogui/commit/77b8d98a90223d6e0eb72188a619fbb153ef6c47 and https://github.com/mitsuba-renderer/nanogui/commit/e3dcfc51a9473d71e8cfb4e7f3020c6219051e03.