polyscope icon indicating copy to clipboard operation
polyscope copied to clipboard

reset cached lazy properties on shutdown

Open gkoulin opened this issue 11 months ago • 2 comments

gkoulin avatar Mar 06 '25 10:03 gkoulin

Thanks for submitting this! Can you say briefly what problem this solves (ie what is the current/expected behavior)?

We don't really have a consistent policy about what should happen to options on a shutdown. Should they go back to the defaults, or stay as-is? But I don't think corresponds to either, it's more about not breaking caching?

nmwsharp avatar Apr 02 '25 08:04 nmwsharp

Problem

What currently happens is that variables inside namespace lazy will keep their state after shutdown. This means that next time you initialise, the renderer may not apply some of the options, if they happen to match those cached by lazy variables.

Example

For example, in my case I would create a point cloud with transparency which sets:

options::transparencyMode = TransparencyMode::Pretty;

But the current lazy state (from previous session) is already set to that, therefore the following branch is skipped. Resulting in opaque rendering.

  if (lazy::transparencyMode != options::transparencyMode) {
    lazy::transparencyMode = options::transparencyMode;
    render::engine->setTransparencyMode(options::transparencyMode);
  }

Solution

The submitted change resets lazy variables states, at shutdown, back to the default initialised. This will make sure that in the next session will correctly apply options to the renderer.

Now that I'm thinking about it, it might be better to reset lazy state to match that of default constructed options, since that is what the renderer is initialised with. Otherwise we have two default initialisation states which don't have to match.

gkoulin avatar Apr 07 '25 14:04 gkoulin