view->SetSize() reports thread safety errors
Posted: 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.
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
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.
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.
Code: Select all
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();
}
I found out that I can get rid of the error by moving providers to the view creation scope
Code: Select all
Noesis::Ptr<Noesis::XamlProvider> xamlProvider = *new NoesisApp::EmbeddedXamlProvider(xamls);
Noesis::Ptr<Noesis::FontProvider> fontProvider = *new NoesisApp::EmbeddedFontProvider(fonts);
NoesisApp::SetThemeProviders(xamlProvider, fontProvider);
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.