n3b
Topic Author
Posts: 5
Joined: 06 Feb 2024, 17:45

view->SetSize() reports thread safety errors

08 Feb 2024, 19:51

Hi, I was trying to integrate Noesis sample into my project and faced several issues in regard to multithreading.
The code is pretty much the same as in integration sample, except I initialize Noesis in main thread, but create/update view in another one.
void noesisUpdate()
{
    if (noesisView == nullptr)
    {
        noesisView = Noesis::GUI::CreateView(Noesis::GUI::LoadXaml<Noesis::UserControl>("Settings.xaml"));
        noesisView->SetFlags(Noesis::RenderFlags_PPAA | Noesis::RenderFlags_LCD);
        noesisView->GetRenderer()->Init(renderDevice);
    }

    static uint64_t startTime = Noesis::HighResTimer::Ticks();
    uint64_t time = Noesis::HighResTimer::Ticks();
    noesisView->SetSize(vk->swapchain.extent().width, vk->swapchain.extent().height);
    noesisView->Update(Noesis::HighResTimer::Seconds(time - startTime));

    noesisView->GetRenderer()->UpdateRenderTree();
    noesisView->GetRenderer()->RenderOffscreen();
    noesisView->GetRenderer()->Render();
}
It reports that content is being owned by another thread even though the view methods are invoked in the same thread where view was created.
I found out that I can get rid of the error by moving providers to the view creation scope
    Noesis::Ptr<Noesis::XamlProvider> xamlProvider = *new NoesisApp::EmbeddedXamlProvider(xamls);
    Noesis::Ptr<Noesis::FontProvider> fontProvider = *new NoesisApp::EmbeddedFontProvider(fonts);
    NoesisApp::SetThemeProviders(xamlProvider, fontProvider);
which I believe implies that views share a common state.
Is it true or is it just an ownership issue and it is safe to assume there is no shared state and views are completely isolated from each other?
If the latter, is it possible to disable thread safety validation? I was going to update many views in fibers-like jobs system and binding views to specific threads would cause significant overhead with performance implications.
 
User avatar
jsantos
Site Admin
Posts: 3925
Joined: 20 Jan 2012, 17:18
Contact:

Re: view->SetSize() reports thread safety errors

15 Feb 2024, 18:48

There is no shared state between Views, they are completely isolated. But I think that the warnings are coming from the fact that the theme is being loaded in the main thread and there must be resources inside it that are not properly sealed.

Could you please open a ticket about this?

We also have plans to expose API (and #define) to disable these checks. For now, you can easily do this by filtering them in your log callback.
 
n3b
Topic Author
Posts: 5
Joined: 06 Feb 2024, 17:45

Re: view->SetSize() reports thread safety errors

16 Feb 2024, 04:14

Great, thanks for confirming!
I'll create a ticket.

Who is online

Users browsing this forum: No registered users and 8 guests