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.

Blazor Hybrid Windows: Window was already activated when minimize and restore from taskbar

See original GitHub issue

Description

I have a Blazor Hybrid app, debugging in Windows. I’m running against maui main.

If I minimize the app and then try to restore it again by clicking on the icon in the taskbar, I get an instacrash:

System.InvalidOperationException
  HResult=0x80131509
  Message=Window was already activated
  Source=Microsoft.Maui.Controls
  StackTrace:
   at Microsoft.Maui.Controls.Window.Microsoft.Maui.IWindow.Activated() in C:\src\github\maui\src\Controls\src\Core\HandlerImpl\Window\Window.Impl.cs:line 491
   at Microsoft.Maui.LifecycleEvents.AppHostBuilderExtensions.<>c.<OnConfigureLifeCycle>b__2_2(Window window, WindowActivatedEventArgs args) in C:\src\github\maui\src\Core\src\Hosting\LifecycleEvents\AppHostBuilderExtensions.Windows.cs:line 32
   at Microsoft.Maui.MauiWinUIWindow.<>c__DisplayClass7_0.<OnActivated>b__1(OnActivated del) in C:\src\github\maui\src\Core\src\Platform\Windows\MauiWinUIWindow.cs:line 51
   at Microsoft.Maui.LifecycleEvents.LifecycleEventServiceExtensions.InvokeLifecycleEvents[TDelegate](IServiceProvider services, Action`1 action) in C:\src\github\maui\src\Core\src\LifecycleEvents\LifecycleEventServiceExtensions.cs:line 31
   at Microsoft.Maui.MauiWinUIWindow.OnActivated(Object sender, WindowActivatedEventArgs args) in C:\src\github\maui\src\Core\src\Platform\Windows\MauiWinUIWindow.cs:line 51
   at ABI.Windows.Foundation.TypedEventHandler`2.Do_Abi_Invoke[TSenderAbi,TResultAbi](Void* thisPtr, TSenderAbi sender, TResultAbi args)

Steps to Reproduce

  1. File > New MAUI Blazor
  2. Run in Windows
  3. Minimize
  4. Restore
  5. 💥

Link to public reproduction project repository

try vigilant guide

Version with bug

Unknown/Other (please specify)

Last version that worked well

7.0 (current)

Affected platforms

Windows, I was not able test on other platforms

Affected platform versions

windows10.0.19041.0

Did you find any workaround?

No response

Relevant log output

No response

Issue Analytics

  • State:closed
  • Created 6 months ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
PureWeencommented, Mar 22, 2023

@samhouts this is an issue with WinAppSDK (can’t find the original issue)

WinUI calls Activated twice when you maximize, and we aren’t debouncing that second call.

I forgot about this when I added this exception 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

The Window.Activated event fires twice after maximizing a ...
Describe the bug If you minimize a window and then maximize it you will get two symmetrical Activated events // Minimize window OnActivated....
Read more >
How To Disable "Restore Down" In .NET MAUI Blazor ...
I have created one .NET MAUI Blazor Component App. I want to restrict users to not restoring down the window. Simply, I want...
Read more >
How to restore a minimized window using AppActivate ...
The trick to making this work all the time is to minimize and then restore. This way, the app flickers, but always restores...
Read more >
Blazor Hybrid (MAUI) - Customize TitleBar
This is a follow-up to a previous question. I now see that the Title Bar customization API only works for Windows 11 (AppWindow....
Read more >
Blazor Hybrid Web Apps with .NET MAUI
With Blazor Hybrid, native desktop on Android, iOS, macOS, and Windows are now ... screen recording, system-tray support for minimized apps, and more....
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