Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessible_HighContrastChanged threading issue in dev/7.0.0 impl of ThemeListener #3253

Closed
0x7c13 opened this issue Apr 25, 2020 · 6 comments · Fixed by #4243
Closed

Accessible_HighContrastChanged threading issue in dev/7.0.0 impl of ThemeListener #3253

0x7c13 opened this issue Apr 25, 2020 · 6 comments · Fixed by #4243
Labels
bug 🐛 An unexpected issue that highlights incorrect behavior Completed 🔥 helpers ✋ in progress 🚧
Milestone

Comments

@0x7c13
Copy link
Contributor

0x7c13 commented Apr 25, 2020

This is regarding to the new dispatcher queue implementation of ThemeListener in dev/7.0.0 branch.

I made a copy of it and embedded it in my own app. Then I am start to seeing this weird exception from some of my users:

Taking look at the source code, I found this:

The error happens within this code path:
_accessible.HighContrastChanged += Accessible_HighContrastChanged;

Since high contrast change will trigger both Accessible_HighContrastChanged event as well as Settings_ColorValuesChanged event at same time. But the dispatcher is only used in Settings_ColorValuesChanged code path but not Accessible_HighContrastChanged path. I was wondering if Accessible_HighContrastChanged is getting fired off UI thread which could leads problem here?

However, after testing, I could not re-pro it on my machine. But it definitely is an issue since not only one of my users but actually 5 of them are affected. That is happening a lot after only one day of release.

Before I jump to the conclusion, I quickly did below changes in my app and the issue is gone:

Can you guys take a look and see if you can find out why this is causing the issue here?

@0x7c13 0x7c13 added the bug 🐛 An unexpected issue that highlights incorrect behavior label Apr 25, 2020
@ghost ghost added the needs triage 🔍 label Apr 25, 2020
@ghost
Copy link

ghost commented Apr 25, 2020

Hello JasonStein, thank you for opening an issue with us!

I have automatically added a "needs triage" label to help get things started. Our team will analyze and investigate the issue, and escalate it to the relevant team if possible. Other community members may also look into the issue and provide feedback 🙌

@0x7c13
Copy link
Contributor Author

0x7c13 commented Apr 25, 2020

@azchohfi

@ghost ghost added the needs attention 👋 label May 10, 2020
@michael-hawker michael-hawker added this to the 7.0 milestone Dec 7, 2020
@CommunityToolkit CommunityToolkit deleted a comment Dec 7, 2020
@CommunityToolkit CommunityToolkit deleted a comment Dec 7, 2020
@CommunityToolkit CommunityToolkit deleted a comment Dec 7, 2020
@CommunityToolkit CommunityToolkit deleted a comment Dec 7, 2020
@CommunityToolkit CommunityToolkit deleted a comment Dec 7, 2020
@CommunityToolkit CommunityToolkit deleted a comment Dec 7, 2020
@CommunityToolkit CommunityToolkit deleted a comment Dec 7, 2020
@CommunityToolkit CommunityToolkit deleted a comment Dec 7, 2020
@CommunityToolkit CommunityToolkit deleted a comment Dec 7, 2020
@CommunityToolkit CommunityToolkit deleted a comment Dec 7, 2020
@CommunityToolkit CommunityToolkit deleted a comment Dec 7, 2020
@CommunityToolkit CommunityToolkit deleted a comment Dec 7, 2020
@CommunityToolkit CommunityToolkit deleted a comment Dec 7, 2020
@CommunityToolkit CommunityToolkit deleted a comment Dec 7, 2020
@CommunityToolkit CommunityToolkit deleted a comment Dec 7, 2020
@michael-hawker
Copy link
Member

@azchohfi @Sergio0694 thoughts on this potential double-update conflict?

@Sergio0694
Copy link
Member

Not super familiar with the ThemeListener class in particular, though I don't see any problems at all adding that dispatcher queue dispatching in the other method as well, makes perfect sense. The TryEnqueue extension (by the way, that code in the screen is a bit out of date, those methods are different now) will skip the dispatching if they already have thread access anyway. Also now that I look at that screen, that async state machine in the second method is not needed and can be removed as well 🙂

@Jasonstein Would you be ok creating a PR based off of master now and do these changes?
We can take care of it otherwise. Thanks for the report!

@Kyaa-dost
Copy link
Contributor

@Jasonstein ⬆️

@Kyaa-dost
Copy link
Contributor

@Jasonstein let us know if you can proceed with the PR

@Kyaa-dost Kyaa-dost modified the milestones: 7.0, 7.1 Feb 18, 2021
@ghost ghost added the In-PR 🚀 label Sep 13, 2021
@ghost ghost added the in progress 🚧 label Sep 13, 2021
@ghost ghost closed this as completed in #4243 Sep 15, 2021
ghost pushed a commit that referenced this issue Sep 15, 2021
<!-- 🚨 Please Do Not skip any instructions and information mentioned below as they are all required and essential to evaluate and test the PR. By fulfilling all the required information you will be able to reduce the volume of questions and most likely help merge the PR faster 🚨 -->

<!-- 👉 It is imperative to resolve ONE ISSUE PER PR and avoid making multiple changes unless the changes interrelate with each other -->

<!-- 📝 Please always keep the "☑️ Allow edits by maintainers" button checked in the Pull Request Template as it increases collaboration with the Toolkit maintainers by permitting commits to your PR branch (only) created from your fork. This can let us quickly make fixes for minor typos or forgotten StyleCop issues during review without needing to wait on you doing extra work. Let us help you help us! 🎉 -->

## Fixes #3253

Applying changes discussed in #3253 (comment).

<!-- Add the relevant issue number after the word "Fixes" mentioned above (for ex: "## Fixes #1234") which will automatically close the issue once the PR is merged. -->

<!-- Add a brief overview here of the feature/bug & fix. -->

## PR Type

What kind of change does this PR introduce?

<!-- Please uncomment one or more options below 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 -->
<!-- - Sample app changes -->
<!-- - Other... Please describe: -->

## What is the current behavior?
Changes to the high contrast theme are propagated on the original synchronization context.
<!-- Please describe the current behavior that you are modifying, or link to a relevant issue. -->

## What is the new behavior?
The event handler now dispatches on the current dispatcher queue.
<!-- Describe how was this issue resolved or changed? -->

## PR Checklist

Please check if your PR fulfills the following requirements: <!-- and remove the ones that are not applicable to the current PR -->

- [X] Tested code with current [supported SDKs](../#supported)
- [X] New component
  - [X] Pull Request has been submitted to the documentation repository [instructions](../blob/main/Contributing.md#docs). Link: <!-- docs PR link -->
  - [X] Added description of major feature to project description for NuGet package (4000 total character limit, so don't push entire description over that)
  - [X] If control, added to Visual Studio Design project
- [X] Sample in sample app has been added / updated (for bug fixes / features)
  - [X] Icon has been created (if new sample) following the [Thumbnail Style Guide and templates](https:/CommunityToolkit/WindowsCommunityToolkit-design-assets)
- [X] New major technical changes in the toolkit have or will be added to the [Wiki](https:/CommunityToolkit/WindowsCommunityToolkit/wiki) e.g. build changes, source generators, testing infrastructure, sample creation changes, etc...
- [X] Tests for the changes have been added (for bug fixes / features) (if applicable)
- [X] Header has been added to all new source files (run _build/UpdateHeaders.bat_)
- [X] Contains **NO** breaking changes
@ghost ghost added Completed 🔥 and removed In-PR 🚀 labels Sep 15, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Nov 14, 2021
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug 🐛 An unexpected issue that highlights incorrect behavior Completed 🔥 helpers ✋ in progress 🚧
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants