Skip to content

Commit

Permalink
fix!: SimpleOrientationSensor should not schedule on Dispatcher (#…
Browse files Browse the repository at this point in the history
…12203)

BREAKING CHANGE: `SimpleOrientationSensor` should not schedule on
`Dispatcher`

GitHub Issue (If applicable): closes #10905, Part of #8339

<!-- Link to relevant GitHub issue if applicable. All PRs should be
associated with an issue (GitHub issue or internal), unless the change
is documentation related. -->

## PR Type

What kind of change does this PR introduce?
<!-- Please uncomment one or more that apply to this PR

- Bugfix
- Feature
- Code style update (formatting)
- Refactoring (no functional changes, no api changes)
- Build or CI related changes
- Documentation content changes
- Project automation
- Other... Please describe:

-->

## What is the current behavior?

<!-- Please describe the current behavior that you are modifying, or
link to a relevant issue. -->


## What is the new behavior?

<!-- Please describe the new behavior after your modifications. -->


## PR Checklist

Please check if your PR fulfills the following requirements:

- [ ] Docs have been added/updated which fit [documentation
template](https://github.com/unoplatform/uno/blob/master/doc/.feature-template.md)
(for bug fixes / features)
- [ ] [Unit Tests and/or UI
Tests](https://github.com/unoplatform/uno/blob/master/doc/articles/uno-development/working-with-the-samples-apps.md)
for the changes have been added (for bug fixes / features) (if
applicable)
- [ ] Validated PR `Screenshots Compare Test Run` results.
- [ ] Contains **NO** breaking changes
- [ ] Associated with an issue (GitHub or internal) and uses the
[automatic close
keywords](https://help.github.com/en/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue).
- [ ] Commits must be following the [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/#summary)
specification.

<!-- If this PR contains a breaking change, please describe the impact
and migration path for existing applications below.
     Please note that breaking changes are likely to be rejected -->

## Other information

<!-- Please provide any additional information if necessary -->

Internal Issue (If applicable):
<!-- Link to relevant internal issue if applicable. All PRs should be
associated with an issue (GitHub issue or internal) -->
  • Loading branch information
jeromelaban authored May 9, 2023
2 parents e9c3572 + 7daa77a commit f6a1281
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 16 deletions.
3 changes: 2 additions & 1 deletion src/Uno.UI/UI/Xaml/ApplicationActivity.Android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using Windows.Security.Authentication.Web;
using Windows.Storage.Pickers;
using Windows.System;
using Windows.UI.Core;
using Windows.UI.ViewManagement;
using Windows.UI.Xaml.Media;
using WinUICoreServices = Uno.UI.Xaml.Core.CoreServices;
Expand Down Expand Up @@ -73,7 +74,7 @@ public override void OnAttachedToWindow()

private void OnSensorOrientationChanged(SimpleOrientationSensor sender, SimpleOrientationSensorOrientationChangedEventArgs args)
{
RaiseConfigurationChanges();
_ = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, RaiseConfigurationChanges);
}

private void OnInputPaneVisibilityChanged(InputPane sender, InputPaneVisibilityEventArgs args)
Expand Down
15 changes: 0 additions & 15 deletions src/Uno.UWP/Devices/Sensors/SimpleOrientationSensor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,6 @@ private SimpleOrientationSensor()

#if __ANDROID__ || __IOS__
private void SetCurrentOrientation(SimpleOrientation orientation)
{
if (CoreDispatcher.Main.HasThreadAccess)
{
CalculateCurrentOrientation(orientation);
}
else
{
_ = CoreDispatcher.Main.RunAsync(CoreDispatcherPriority.Normal, () =>
{
CalculateCurrentOrientation(orientation);
});
}
}

private void CalculateCurrentOrientation(SimpleOrientation orientation)
{
if (_currentOrientation != orientation)
{
Expand Down

0 comments on commit f6a1281

Please sign in to comment.