mikke89 / RmlUi

RmlUi - The HTML/CSS User Interface library evolved
https://mikke89.github.io/RmlUiDoc/
MIT License
2.84k stars 310 forks source link

Assertion failed when removing context-specific render interface after calling Rml::RemoveContext() #703

Open maxamula opened 3 days ago

maxamula commented 3 days ago

In one of the recent updates, support was added for assigning a render interface to each context in RmlUI. I encountered an issue when dynamically creating and later deleting a custom render interface tied to a specific context.

Steps to Reproduce:

Create a custom render interface class. Create an instance of render interface dynamically. Create a context that uses this custom render interface. After completing work with the context, call Rml::RemoveContext() to delete the context. Attempt to delete the custom render interface that was tied to this context.

Expected Behavior:

The render interface should no longer be in use after the context is removed, and it should be safe to delete it without waiting for a global RmlUi::Shutdown().

Actual Behavior:

An assertion failed error is triggered, indicating that the render interface may still be in use by RmlUI operations, and suggesting to wait for global shutdown via RmlUi::Shutdown(). However, this render interface is not global and was only used for operations on a specific context.

image

mikke89 commented 3 days ago

Oh I see. Yeah, looks like we lost this ability during some of the larger changes for RmlUi 6.0. There is a lifetime annotation note about having to call Rml::ReleaseTextures also before destroying the render interface, but I think there's a separate issue on the library side here. I'll take a closer look at it.

mikke89 commented 3 days ago

I pushed some changes to master now that (hopefully) make this work again. I also added a test for it, so we know about any future regressions.

You will have to manually call into Rml::ReleaseRenderManagers after removing the context, before you're allowed to erase the render interface. But you no longer need to call Rml::ReleaseTextures.

It would be great if you could test this. There could still be some more complicated situations that needs some more work, but hopefully you should hit an error or assertion in that case. Let me know how it works out for you.