Skip to content

Commit

Permalink
fix(wasm): Failsafe on finalization of UIElement
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromelaban committed Jan 22, 2022
1 parent 3e37c5e commit d662bf1
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/Uno.UI/UI/Xaml/UIElement.wasm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,24 @@ private string GetHtmlTag(string htmlTag)

~UIElement()
{
if (this.Log().IsEnabled(Uno.Foundation.Logging.LogLevel.Debug))
try
{
this.Log().Debug($"Collecting UIElement for [{HtmlId}]");
}
if (this.Log().IsEnabled(Uno.Foundation.Logging.LogLevel.Debug))
{
this.Log().Debug($"Collecting UIElement for [{HtmlId}]");
}

Cleanup();
Cleanup();

Uno.UI.Xaml.WindowManagerInterop.DestroyView(HtmlId);
Uno.UI.Xaml.WindowManagerInterop.DestroyView(HtmlId);
}
catch (Exception e)
{
if (this.Log().IsEnabled(Uno.Foundation.Logging.LogLevel.Warning))
{
this.Log().Warn($"Collection of UIElement for [{HtmlId}] failed", e);
}
}

_gcHandle.Free();
}
Expand Down

0 comments on commit d662bf1

Please sign in to comment.