Description
Description
I encountered a very odd behavior where Vector3
sum is invalid on Android under very specific circumstances.
Consider the following method, which logs the value of total
variable and then returns the exact same sum in return
statement.
private Vector3 GetTotalOffset()
{
if (IsTranslationEnabled && Properties.TryGetVector3("Translation", out var translation) == CompositionGetValueStatus.Success)
{
var total = Offset + translation;
UIDebugLog.Log($"Total: {total}");
return (Offset + translation);
}
return Offset;
}
This method is used as follows:
var totalOffset = GetTotalOffset();
if (IsRefresh)
{
UIDebugLog.Log($"Total2: {totalOffset}");
}
Technically the Total1
and Total2
values should have the exact same value. Surprisingly, this is the case only in debug mode with debugger attached:
However, in Release mode or in Debug mode without debugger attached we are getting invalid results from the return
statement:
Reproduction Steps
- Clone unoplatform/uno@af0a060
- Rename
src\crosstargeting_override.props.sample
tosrc\crosstargeting_override.props
- Inside this file, uncomment
UnoTargetFrameworkOverride
and change it to<UnoTargetFrameworkOverride>net9.0-android</UnoTargetFrameworkOverride>
- Open
src\Uno.UI-Skia-only.slnf
- Run
SamplesApp.Skia.netcoremobile
with debugger attached - Search for
RefreshContainerNavigation
sample and open it - Note the refresh container behaves as expected - the indicator only shows up when the list is pulled down
- Note the logged
Total1
andTotal2
values in the bottom are equal - Stop debugging and open the app again without debugger
- Navigate to the
RefreshContainerNavigation
sample - Note the refresh indicator is misaligned
- Note the logged
Total1
andTotal2
values in the bottom are not equal
Expected behavior
Sum of Vector3
values should be reliable.
Actual behavior
Sum of Vector3
values differs when done within a local variable vs. within a return statement on Android.
Regression?
No response
Known Workarounds
Perform the sum manually, per vector element.
Configuration
No response
Other information
No response