dotnet / winforms

Windows Forms is a .NET UI framework for building Windows desktop applications.
MIT License
4.39k stars 975 forks source link

In Designer, Nesting a TreeView in a UserControl in a second TabPage on a Form hangs DesignServerTools.exe #4336

Open The-MAZZTer opened 3 years ago

The-MAZZTer commented 3 years ago

Apologies if this is not the right repo to post this in.

[Edit: I found instruction to send feedback using the VS Feedback tool in Visual Studio and I have done so, please close this issue here if it is not appropriate for this repo.]

Problem description: In the designer, upon activating a second tab page containing a User Control with a TreeView in it, VS hangs.

Expected behavior: Visual Studio does not hang and the designer continues to work normally.

Minimal repro: SetFocusBug.zip

This project was created with the following steps:

If using the attached project, build before opening the form (hang does not happen until build is made and designer reopened).

You may also need to rebuild in that VS session, or with the designer open. I am seeing inconsistent behavior where the designer does not show the User Control at all after I open the project in a fresh session of VS.

These variants of the project do NOT produce any hangs or other undesirable behavior:

I attempted to debug both VS and DesignServerTools but I am not sure exactly what I am looking at.

VS' UI thread seems to hang waiting for a response from the DesignServerTools for a Hit Test on the designer or a control or something.

One of the DesignServerTools threads that stuck out to me seems to get struck calling the native SetFocus WinAPI whenever I happened to pause it. It seems to call it but the call never completes if I try to step over it.

Killing the DesignServerTools process tends to allow VS to recover so I believe the problem lies with DesignServerTools.

Zheng-Li01 commented 3 years ago

Failed to repro the issue following the steps based on The-MAZZTer's description, however reproduce the issue after click "Add Tab"/"Remove Tab". see below repro GIF. UpdateCoreIssue in addition, there have a similar known 2632 issue in Design repo to track it.

The-MAZZTer commented 3 years ago

On my Developer Community thread a similar known issue was posted. I reproduced and debugged it and it appears very similar to what I am seeing in my issue, so it is likely the same problem.

https://developercommunity2.visualstudio.com/t/Nesting-a-TreeView-in-a-UserControl-in-a/1280521

RussKie commented 3 years ago

Thank you. The issue is being tracked in the designer repo, and it is expected to be fixed in 16.9.

RussKie commented 2 years ago

@Zheng-Li01 can you please if this still repros? If not - please close.

Cassie-Li01 commented 2 years ago

The issue can repro on version 17.2.0 Preview 2.1 download from: https://visualstudio.microsoft.com/vs/preview/

repro steps:

  1. Create a Windows Form App (.NET) project.
  2. Open Form1 in the designer.
  3. Add a TabControl and keep the two tabs.
  4. Add a User Control to the project. Open it in design mode.
  5. Add a TreeView to the User Control and build the project to compile it.
  6. Add the User Control to the second TabPage on the Form.
  7. Save form.
  8. Switch to the first TabPage and then back to the second and the hang should occur. still repro

in addition, there is a similar known issue https://github.com/dotnet/winforms-designer/issues/2632 in Design repo to track it.

JeremyKuhne commented 1 year ago

Note that #9002 may be the same root issue