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

Can't get Screens in Design Preview in 11.2.0 #17401

Closed
Coloryr opened this issue Nov 1, 2024 · 8 comments · Fixed by #17409
Closed

Can't get Screens in Design Preview in 11.2.0 #17401

Coloryr opened this issue Nov 1, 2024 · 8 comments · Fixed by #17409

Comments

@Coloryr
Copy link
Contributor

Coloryr commented Nov 1, 2024

10:03:18.175 [Error] 28276 <= "Unhandled exception. System.InvalidOperationException: Windowing backend wasn't properly initialized."
10:03:18.177 [Error] 28276 <= "   at Avalonia.Controls.WindowBase.get_Screens()"
10:03:18.177 [Error] 28276 <= "   at ColorMC.Gui.UI.Windows.ABaseWindow.SetWindowState() in E:\code\ColorMC\src\ColorMC.Gui\UI\Windows\ABaseWindow.cs:line 114"
10:03:18.178 [Error] 28276 <= "   at ColorMC.Gui.UI.Windows.AMultiWindow.FindGoodPos() in E:\code\ColorMC\src\ColorMC.Gui\UI\Windows\AMultiWindow.cs:line 140"
10:03:18.178 [Error] 28276 <= "   at ColorMC.Gui.UI.Windows.AMultiWindow.InitMultiWindow(BaseUserControl con) in E:\code\ColorMC\src\ColorMC.Gui\UI\Windows\AMultiWindow.cs:line 62"
10:03:18.178 [Error] 28276 <= "   at ColorMC.Gui.UI.Windows.MultiWindow..ctor(BaseUserControl con) in E:\code\ColorMC\src\ColorMC.Gui\UI\Windows\MultiWindow.axaml.cs:line 22"
10:03:18.179 [Error] 28276 <= "   at ColorMC.Gui.Manager.WindowManager.ShowWindow(BaseUserControl con) in E:\code\ColorMC\src\ColorMC.Gui\Manager\WindowManager.cs:line 212"
10:03:18.179 [Error] 28276 <= "   at ColorMC.Gui.Manager.WindowManager.AWindow(BaseUserControl con, Boolean newwindow) in E:\code\ColorMC\src\ColorMC.Gui\Manager\WindowManager.cs:line 238"
10:03:18.179 [Error] 28276 <= "   at ColorMC.Gui.Manager.WindowManager.ShowMain() in E:\code\ColorMC\src\ColorMC.Gui\Manager\WindowManager.cs:line 366"
10:03:18.179 [Error] 28276 <= "   at ColorMC.Gui.Manager.WindowManager.Init(String path) in E:\code\ColorMC\src\ColorMC.Gui\Manager\WindowManager.cs:line 120"
10:03:18.180 [Error] 28276 <= "   at ColorMC.Gui.App.OnFrameworkInitializationCompleted() in E:\code\ColorMC\src\ColorMC.Gui\App.axaml.cs:line 103"
10:03:18.180 [Error] 28276 <= "   at Avalonia.AppBuilder.SetupUnsafe()"
10:03:18.180 [Error] 28276 <= "   at Avalonia.AppBuilder.Setup()"
10:03:18.182 [Error] 28276 <= "   at Avalonia.AppBuilder.SetupWithoutStarting()"
10:03:18.182 [Error] 28276 <= "   at Avalonia.DesignerSupport.Remote.RemoteDesignerEntryPoint.AppInitializer.ConfigureApp(IAvaloniaRemoteTransportConnection transport, CommandLineArgs args, Object obj)"
10:03:18.182 [Error] 28276 <= "   at Avalonia.DesignerSupport.Remote.RemoteDesignerEntryPoint.Main(String[] cmdline)"
10:03:18.183 [Error] 28276 <= "   at Avalonia.Designer.HostApp.Program.Main(String[] args)"

https://github.com/Coloryr/ColorMC/blob/9c0fe2d4e543e38d7d26c06f57a3f77f194c832c/src/ColorMC.Gui/UI/Windows/ABaseWindow.cs#L114

Originally posted by @Coloryr in #17395

@Coloryr Coloryr changed the title Can't get Screens in Design Preview Can't get Screens in Design Preview in 11.2.0 Nov 1, 2024
@timunie
Copy link
Contributor

timunie commented Nov 1, 2024

Maybe you try to access it too early? Try Dispatcher.UiThread.Post to wait for window to be loaded.

@timunie
Copy link
Contributor

timunie commented Nov 1, 2024

Wait the previewer doesn't know about screens at all afaik. So if you are seeing it in the designer, this is probably by design.

@thevortexcloud
Copy link
Contributor

thevortexcloud commented Nov 1, 2024

As was mentioned in the discussion, it does in fact have an implementation for Screens and it does look like it's wired up properly.

#17395 (reply in thread)

I am however not clear why it's not working as it looks fine to me just from looking at the code. The exception can only happen if for some reason Screens returns null, which it should never do.

The only thing that makes sense is if PlatformImpl is null. When that gets made not null though I am not sure.

@maxkatz6
Copy link
Member

maxkatz6 commented Nov 1, 2024

I actually tried to reproduce this issue using new AvaloniaRider feature, allowing to debug designer process.

It works fine here:
image

@maxkatz6
Copy link
Member

maxkatz6 commented Nov 1, 2024

@Coloryr can you try to isolate the issue? Maybe project configuration overrides backend or breaks something unexpectedly.

@Coloryr
Copy link
Contributor Author

Coloryr commented Nov 2, 2024

I know what happend, I opened a new window on OnFrameworkInitializationCompleted, and the new window to get the Screens, like your pic.

I actually tried to reproduce this issue using new AvaloniaRider feature, allowing to debug designer process.

It works fine here: image

And the new window will also open in preview.

@Coloryr
Copy link
Contributor Author

Coloryr commented Nov 2, 2024

@Coloryr
Copy link
Contributor Author

Coloryr commented Nov 2, 2024

11.1.4 is work well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants