I'm using the C library in an off-screen rendering context to:
1. Initialize cef
2. Wait for context to be initialized
3. Run message loop
4. Sleep 3s
5. Create a browser
6. Do something with the browser once it's created
7. Sleep 1s
8. Close the browser
9. Sleep 1s
10. Shutdown
However, on shutdown I get the following error:
- Code: Select all
Check failed: global_request_context_->HasOneRef()
Based on this post, it seems it's related to the global_request_context not being released properly and more precisely a reference to a browser https://magpcss.org/ceforum/viewtopic.php?f=6&t=16450
However I'm closing the browser and the on_before_close life span callback is being hit. I never call the cef_browser_t->base.add_ref() method therefore, if I understood things correctly, I don't need to release anything. Or did I understand it wrong?
I took a look at the doc but I still have questions: https://bitbucket.org/chromiumembedded/cef/wiki/UsingTheCAPI.md
Decrement the reference count on a struct when receiving it as an argument from somewhere else after you're done using it:
Does that mean that in handlers methods like life_span_handler->on_after_created or render_handler->get_view_rect I should call cef_browser_t->base.release() explicitely?
Reverse any additional references that your code adds to a struct
If cef_browser_t->base.add_ref() is not called explicitely in the code at the moment of storing the browser somewhere, is it mandatory to call cef_browser_t->base.release() nonetheless? (this is purely theoretical so that I understand the logic behind).
Thanks in advance.
Cheers
Bob