Skip to content

Commit

Permalink
perf: Remove try/catch handling in OnFwElt Loading/Loaded/Unloaded
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromelaban committed Sep 14, 2021
1 parent 9cae465 commit 17f2e4f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Uno.UI/UI/Xaml/FrameworkElement.netstd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,21 @@ private protected sealed override void OnFwEltLoading()
OnLoadingPartial();
ApplyCompiledBindings();

#if !HAS_EXPENSIVE_TRYFINALLY // Try/finally incurs a very large performance hit in mono-wasm - https://github.com/dotnet/runtime/issues/50783
try
{
#endif
// Raise event before invoking base in order to raise them top to bottom
OnLoading();
_loading?.Invoke(this, new RoutedEventArgs(this));
#if !HAS_EXPENSIVE_TRYFINALLY // Try/finally incurs a very large performance hit in mono-wasm - https://github.com/dotnet/runtime/issues/50783
}
catch (Exception error)
{
_log.Error("OnElementLoading failed in FrameworkElement", error);
Application.Current.RaiseRecoverableUnhandledException(error);
}
#endif

OnPostLoading();
}
Expand All @@ -52,36 +56,44 @@ private protected sealed override void OnFwEltLoaded()
{
OnLoadedPartial();

#if !HAS_EXPENSIVE_TRYFINALLY // Try/finally incurs a very large performance hit in mono-wasm - https://github.com/dotnet/runtime/issues/50783
try
{
#endif
// Raise event before invoking base in order to raise them top to bottom
OnLoaded();
_loaded?.Invoke(this, new RoutedEventArgs(this));
#if !HAS_EXPENSIVE_TRYFINALLY // Try/finally incurs a very large performance hit in mono-wasm - https://github.com/dotnet/runtime/issues/50783
}
catch (Exception error)
{
_log.Error("OnElementLoaded failed in FrameworkElement", error);
Application.Current.RaiseRecoverableUnhandledException(error);
}
#endif
}

partial void OnLoadedPartial();
private protected virtual void OnLoaded() { }

private protected sealed override void OnFwEltUnloaded()
{
#if !HAS_EXPENSIVE_TRYFINALLY // Try/finally incurs a very large performance hit in mono-wasm - https://github.com/dotnet/runtime/issues/50783
try
{
#endif
// Raise event after invoking base in order to raise them bottom to top
OnUnloaded();
_unloaded?.Invoke(this, new RoutedEventArgs(this));
OnUnloadedPartial();
#if !HAS_EXPENSIVE_TRYFINALLY // Try/finally incurs a very large performance hit in mono-wasm - https://github.com/dotnet/runtime/issues/50783
}
catch (Exception error)
{
_log.Error("OnElementUnloaded failed in FrameworkElement", error);
Application.Current.RaiseRecoverableUnhandledException(error);
}
#endif
}
partial void OnUnloadedPartial();

Expand Down

0 comments on commit 17f2e4f

Please sign in to comment.