You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am receiving multiple "Publishing changes from within view updates is not allowed, this will cause undefined behavior" warning in iOS 18.3.1. This happens for example when a LaTeX view is conditionally displayed, e.g.:
I found a solution, but I am not sure if it captures the essence of the renderSync function:
@MainActorfunc renderSync(
latex:String,
unencodeHTML:Bool,
parsingMode:LaTeX.ParsingMode,
processEscapes:Bool,
errorMode:LaTeX.ErrorMode,
font:Font,
displayScale:CGFloat,
renderingMode:SwiftUI.Image.TemplateRenderingMode)->[ComponentBlock]{guard !isRendering else{return[]}guard !rendered else{return blocks
}lettexOptions=TeXInputProcessorOptions(processEscapes: processEscapes, errorMode: errorMode)letrenderedBlocks=render(
blocks:parseBlocks(latex: latex, unencodeHTML: unencodeHTML, parsingMode: parsingMode),
font: font,
displayScale: displayScale,
renderingMode: renderingMode,
texOptions: texOptions)
// Schedule updates for the next view cycle on the main actor outside the current view update
Task{awaitMainActor.run{
isRendering =true
blocks = renderedBlocks
isRendering =false
rendered =true}}return renderedBlocks
}
Now, it still computes and returns the new renderedBlocks synchronously, but they are only registered for the next view cycle in the UI (I believe).
I tried the .wait rendering method with my approach, and it still seems to block the UI, just like the first version did. But I am obviously unsure if this is the way to go and if I should create a PR.
The text was updated successfully, but these errors were encountered:
I am receiving multiple "Publishing changes from within view updates is not allowed, this will cause undefined behavior" warning in iOS 18.3.1. This happens for example when a
LaTeX
view is conditionally displayed, e.g.:The issue is the
renderSync
function, specifically where variables are set:I found a solution, but I am not sure if it captures the essence of the
renderSync
function:Now, it still computes and returns the new
renderedBlocks
synchronously, but they are only registered for the next view cycle in the UI (I believe).I tried the
.wait
rendering method with my approach, and it still seems to block the UI, just like the first version did. But I am obviously unsure if this is the way to go and if I should create a PR.The text was updated successfully, but these errors were encountered: