question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FindElement.Refresh stuck in infinite loop when setting a child's events source to the parent's

See original GitHub issue

Describe the bug If you set a control’s events source to a parent’s, the foreach loop in FindElement.Refresh() will get stuck in an infinite loop.

Steps to reproduce the bug Try this code: XAML:

<local:TestControl x:Name="CustomControl" AutomationProperties.Name="CustomControl">
                    <Button x:Name="Button1" Content="Button"/>
 </local:TestControl>

XAML.CS

namespace MUXControlsTestApp
{
    public sealed class TestControl : ContentControl
    {
        protected override AutomationPeer OnCreateAutomationPeer()
        {
            return new TestControlAutomationPeer(this);
        }
    }

    public sealed class TestControlAutomationPeer : FrameworkElementAutomationPeer
    {
        public TestControlAutomationPeer(TestControl owner) : base(owner){}
        protected override AutomationControlType GetAutomationControlTypeCore()
        {
            return AutomationControlType.Custom;
        }
    }

    [TopLevelTestPage(Name = "Expander")]
    public sealed partial class ExpanderPage : TestPage
    {
        public ExpanderPage()
        {
            this.InitializeComponent();
            var customControlPeer = FrameworkElementAutomationPeer.FromElement(CustomControl);
            var buttonPeer= FrameworkElementAutomationPeer.FromElement(Button1);

            buttonPeer.EventsSource = customControlPeer;
        }
    }
}

Expected behavior

Screenshots

Version Info

NuGet package version:

Windows app type:

UWP Win32
Windows 10 version Saw the problem?
Insider Build (xxxxx)
May 2020 Update (19041)
November 2019 Update (18363)
May 2019 Update (18362)
October 2018 Update (17763)
April 2018 Update (17134)
Fall Creators Update (16299)
Creators Update (15063)
Device form factor Saw the problem?
Desktop
Xbox
Surface Hub
IoT

Additional context

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
chingucodingcommented, Oct 28, 2020

It seems that this is not an issue with the test infra, but rather the underlying framework/library that provides us with the UIObject objects. In the scenario described by @ejserna , the list of descendants seems to be infinite, at some point it keeps containing the same element over and over again. So the only efficient solution I can think of is save the previous element and break the for loop if the previous element is equal to the current item, does that sound reasonable as a workaround?

0reactions
eduardoaguacatecommented, Oct 28, 2020

@chingucoding I think that’s a good workaround, at least that’s what @alexhinz and I thought would make sense.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ember.js Route: How to avoid infinite loop when refreshing ...
To answer directly, there is no way to only refresh the parent route. You might, however, be able to just reload the model...
Read more >
3 ways to cause an infinite loop in React - Alex Sidorenko
Set a function to onClick event. It is a proper way to set event handlers. This way state will only update after a...
Read more >
IntelliJ IDEA 2023.1 (231.8109.175 build) Release Notes
Bug, IDEA-309755, Micronaut: if both parent and child beans exist, attempt to inject child beans as qualified dependency of parent type is reported...
Read more >
https://np.edu/_resources/js/build/wy.bundle.js.map
n // for some reason Chrome can't handle source map in server-rendered\n ... {\n warn(\n 'You may have an infinite update loop '...
Read more >
Untitled
Ori design studio, Sociology book in urdu pdf free download, Sabat orthodontics brecksville, Macross delta vf 31f, Bike hire mapua nz, Can a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found