Skip to content

Commit fb22656

Browse files
committed
perf(wasm): Don't use try/finally in Grid measure/arrange
1 parent 5b112e9 commit fb22656

File tree

1 file changed

+25
-2
lines changed
  • src/Uno.UI/UI/Xaml/Controls/Grid

1 file changed

+25
-2
lines changed

src/Uno.UI/UI/Xaml/Controls/Grid/Grid.cs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,14 +1034,25 @@ protected override XSIZEF MeasureOverride(XSIZEF availableSize)
10341034
//{
10351035
// UnlockDefinitions();
10361036
//});
1037+
1038+
#if !HAS_EXPENSIVE_TRYFINALLY // Try/finally incurs a very large performance hit in mono-wasm - https://github.com/dotnet/runtime/issues/50783
10371039
try
10381040
{
1039-
return InnerMeasureOverride(availableSize);
1041+
#endif
1042+
var result = InnerMeasureOverride(availableSize);
1043+
1044+
#if HAS_EXPENSIVE_TRYFINALLY // Try/finally incurs a very large performance hit in mono-wasm - https://github.com/dotnet/runtime/issues/50783
1045+
UnlockDefinitions();
1046+
#endif
1047+
1048+
return result;
1049+
#if !HAS_EXPENSIVE_TRYFINALLY // Try/finally incurs a very large performance hit in mono-wasm - https://github.com/dotnet/runtime/issues/50783
10401050
}
10411051
finally
10421052
{
10431053
UnlockDefinitions();
10441054
}
1055+
#endif
10451056
}
10461057

10471058
/// <remarks>
@@ -1334,16 +1345,28 @@ protected override XSIZEF ArrangeOverride(XSIZEF finalSize)
13341345
// Locking the row and columns definitions to prevent changes by user code
13351346
// during the arrange pass.
13361347
LockDefinitions();
1348+
#if !HAS_EXPENSIVE_TRYFINALLY
13371349
try
13381350
{
1339-
return InnerArrangeOverride(finalSize);
1351+
#endif
1352+
var result = InnerArrangeOverride(finalSize);
1353+
1354+
#if HAS_EXPENSIVE_TRYFINALLY
1355+
m_ppTempDefinitions = null;
1356+
m_cTempDefinitions = 0;
1357+
UnlockDefinitions();
1358+
#endif
1359+
return result;
1360+
1361+
#if !HAS_EXPENSIVE_TRYFINALLY
13401362
}
13411363
finally
13421364
{
13431365
m_ppTempDefinitions = null;
13441366
m_cTempDefinitions = 0;
13451367
UnlockDefinitions();
13461368
}
1369+
#endif
13471370
}
13481371

13491372
/// <remarks>

0 commit comments

Comments
 (0)