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

Backdrop APIs in 1.3 still require the window to have some content #8416

Closed
Balkoth opened this issue Apr 14, 2023 · 5 comments
Closed

Backdrop APIs in 1.3 still require the window to have some content #8416

Balkoth opened this issue Apr 14, 2023 · 5 comments
Labels
bug Something isn't working team-Rendering Issue for the Rendering team
Milestone

Comments

@Balkoth
Copy link

Balkoth commented Apr 14, 2023

Seems like for the new XAML Backdrop APIs to work you have to have both a xaml and a xaml.cs file?

Just doing it like this crashes the application with code 3221226107 (0xc000027b):

public partial class App : Application
{
  public App()
  {
    this.InitializeComponent();
  }

  protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
  {
    m_window = new Window();
    m_window.SystemBackdrop = new DesktopAcrylicBackdrop();
    m_window.Activate();
  }

  private Window m_window;
}

Originally posted by @Balkoth in microsoft/WindowsAppSDK#3406 (comment)

@Balkoth
Copy link
Author

Balkoth commented Apr 14, 2023

Doing it the new way with content before activating the SystemBackdrop crashes my app "HouseMoney" when minimizing it through the taskbar:

private void CreateAndActivateMainWindow()
{
  // Create window and set the title to the app name appended by the executing user.
  _mainWindow = new Window() { Title = $"HouseMoney - {Environment.UserName}" };

  // Enable desktop acrylic backround if supported.
  if (DesktopAcrylicController.IsSupported())
  {
	_mainWindow.Content = new Microsoft.UI.Xaml.Controls.Grid();
	_mainWindow.SystemBackdrop = new DesktopAcrylicBackdrop();

	// Create a dispatcher queue controller if required.
	/*if (DispatcherQueue.GetForCurrentThread() == null)
	{
	  NativeMethods.DispatcherQueueOptions options;
	  options.dwSize = (uint)Marshal.SizeOf(typeof(NativeMethods.DispatcherQueueOptions));
	  options.threadType = NativeMethods.DQTYPE_THREAD_CURRENT;
	  options.apartmentType = NativeMethods.DQTAT_COM_STA;
	  NativeMethods.CreateDispatcherQueueController(options, out nint _);
	}

	// Initial configruation for the system backdrop.
	_systemBackdropConfiguration = new SystemBackdropConfiguration() { IsInputActive = true };
	switch (Current.RequestedTheme)
	{
	  case ApplicationTheme.Light: _systemBackdropConfiguration.Theme = SystemBackdropTheme.Light; break;
	  case ApplicationTheme.Dark: _systemBackdropConfiguration.Theme = SystemBackdropTheme.Dark; break;
	}

	// Hanlde window activation event to set the correct backdrop state.
	_mainWindow.Activated += (sender, args) => { if (_systemBackdropConfiguration != null) { _systemBackdropConfiguration.IsInputActive = args.WindowActivationState != WindowActivationState.Deactivated; } };

	// On closing the window disconnect the controller and clean up.
	_mainWindow.Closed += (sender, args) =>
	{
	  _desktopAcrylicController?.Dispose();
	  _desktopAcrylicController = null;
	  _systemBackdropConfiguration = null;
	};

	// Enable the system backdrop on the main window.
	_desktopAcrylicController = new DesktopAcrylicController();
	_desktopAcrylicController.AddSystemBackdropTarget(_mainWindow.As<ICompositionSupportsSystemBackdrop>());
	_desktopAcrylicController.SetSystemBackdropConfiguration(_systemBackdropConfiguration);*/
  }

  // Ready for activation.
  _mainWindow.Activate();
}
KernelBase.dll!RaiseFailFastException()	Unknown
combase.dll!RoFailFastWithErrorContextInternal2(HRESULT hrError, unsigned long cStowedExceptions, _STOWED_EXCEPTION_INFORMATION_V2 * * aStowedExceptionPointers) Line 1455	C++
Microsoft.ui.xaml.dll!DirectUI::SystemBackdrop::PerTargetConfigurationEntry::AttachActualThemeChanged(void)	Unknown
Microsoft.ui.xaml.dll!DirectUI::SystemBackdrop::PerTargetConfigurationEntry::OnXamlRootChanged(struct ABI::Microsoft::UI::Xaml::IXamlRoot *,struct ABI::Microsoft::UI::Xaml::IXamlRootChangedEventArgs *)	Unknown
Microsoft.ui.xaml.dll!DirectUI::CEventSourceBase<DirectUI::IUntypedEventSource,ABI::Windows::Foundation::ITypedEventHandler<ABI::Microsoft::UI::Xaml::XamlRoot *,ABI::Microsoft::UI::Xaml::XamlRootChangedEventArgs *>,ABI::Microsoft::UI::Xaml::IXamlRoot,ABI::Microsoft::UI::Xaml::IXamlRootChangedEventArgs>::Raise()	Unknown
Microsoft.ui.xaml.dll!DirectUI::XamlRoot::RaiseChangedEvent()	Unknown
Microsoft.ui.xaml.dll!FxCallbacks::XamlRoot_RaiseChanged(struct IInspectable *)	Unknown
Microsoft.ui.xaml.dll!CContentRoot::RaisePendingXamlRootChangedEventIfNeeded(void)	Unknown
Microsoft.ui.xaml.dll!XamlRootStateChangedRaiiHelper::~XamlRootStateChangedRaiiHelper(void)	Unknown
Microsoft.ui.xaml.dll!CXamlIslandRoot::OnStateChanged()	Unknown
Microsoft.ui.xaml.dll!Microsoft::WRL::Details::DelegateArgTraits<long (__cdecl ABI::Windows::Foundation::ITypedEventHandler_impl<ABI::Windows::Foundation::Internal::AggregateType<ABI::Microsoft::UI::Content::ContentIsland *,ABI::Microsoft::UI::Content::IContentIsland *>,ABI::Windows::Foundation::Internal::AggregateType<ABI::Microsoft::UI::Content::ContentIslandEventArgs *,ABI::Microsoft::UI::Content::IContentIslandEventArgs *>>::*)(ABI::Microsoft::UI::Content::IContentIsland *,ABI::Microsoft::UI::Content::IContentIslandEventArgs *)>::DelegateInvokeHelper<Microsoft::WRL::Implements<Microsoft::WRL::RuntimeClassFlags<2>,ABI::Windows::Foundation::ITypedEventHandler<ABI::Microsoft::UI::Content::ContentIsland *,ABI::Microsoft::UI::Content::ContentIslandEventArgs *>,Microsoft::WRL::FtmBase>,`CContentRoot::RegisterCompositionContent'::`3'::<lambda_1> &,1,ABI::Microsoft::UI::Content::IContentIsland *,ABI::Microsoft::UI::Content::IContentIslandEventArgs *>::Invoke()	Unknown
Microsoft.UI.Input.dll!Microsoft::WRL::Details::DelegateArgTraits<long >::DelegateInvokeHelper<struct Microsoft::WRL::Implements<struct Microsoft::WRL::RuntimeClassFlags<2>,struct Windows::Foundation::ITypedEventHandler<class Microsoft::UI::Content::ContentIsland *,class Microsoft::UI::Content::ContentIslandEventArgs *>,class Microsoft::WRL::FtmBase>,class <lambda_ef206b6764de459484cccf886c1cf270>,-1,struct Microsoft::UI::Content::IContentIsland *,struct Microsoft::UI::Content::IContentIslandEventArgs *>::Invoke(struct Microsoft::UI::Content::IContentIsland *,struct Microsoft::UI::Content::IContentIslandEventArgs *)	Unknown
Microsoft.UI.Input.dll!Microsoft::WRL::InvokeTraits<-2>::InvokeDelegates<<lambda_f32fcf27214abf0767e690b55f218dda>,Windows::Foundation::ITypedEventHandler<Microsoft::UI::Content::ContentIsland *,Microsoft::UI::Content::ContentIslandEventArgs *>>()	Unknown
Microsoft.UI.Input.dll!Microsoft::WRL::EventSource<Windows::Foundation::ITypedEventHandler<Microsoft::UI::Content::ContentIsland *,Microsoft::UI::Content::ContentIslandEventArgs *>,Microsoft::WRL::InvokeModeOptions<-2>>::DoInvoke<<lambda_f32fcf27214abf0767e690b55f218dda>>()	Unknown
Microsoft.UI.Input.dll!Microsoft::WRL::EventSource<struct Windows::Foundation::ITypedEventHandler<class Microsoft::UI::Content::ContentIsland *,class Microsoft::UI::Content::ContentIslandEventArgs *>,struct Microsoft::WRL::InvokeModeOptions<-2> >::InvokeAll<struct Microsoft::UI::Content::IContentIsland *,struct Microsoft::UI::Content::IContentIslandEventArgs *>(struct Microsoft::UI::Content::IContentIsland *,struct Microsoft::UI::Content::IContentIslandEventArgs *)	Unknown
Microsoft.UI.Input.dll!Microsoft::WRL2::ContextSession::LeaveSession_Callback<<lambda_40df67bfe783ea1ab670faa59fc78746>>()	Unknown
Microsoft.UI.Input.dll!Microsoft::WRL2::ContextRuntimeClass::LeaveSessionAndValidate_Callback<<lambda_40df67bfe783ea1ab670faa59fc78746>>()	Unknown
Microsoft.UI.Input.dll!ContentIsland::ProcessFinalStateChange_Callback()	Unknown
Microsoft.UI.Input.dll!ContentIsland::ProcessDirty_Callback()	Unknown
Microsoft.UI.Input.dll!Microsoft::WRL2::ApiEntryForwarder_Callback_HResult<long (__cdecl ContentIsland::*)(void),ContentIsland>()	Unknown
Microsoft.UI.Input.dll!ContentIsland::ContentNodeProc_NoLock()	Unknown
Microsoft.UI.Windowing.Core.dll!Core::YieldAndCall::ContentNodeHandler(enum Api::ContentNodeProc,struct System::IntPtr,enum Api::ContentNodeAction,struct System::IntPtr)	Unknown
Microsoft.UI.Windowing.Core.dll!Content::ExternalContentNode::DoWork(enum Content::WorkType)	Unknown
Microsoft.UI.Windowing.Core.dll!Content::ContentNodeManager::DoPerNodeWork(enum Content::WorkType,struct CFlat::Ref<enum Content::WorkType>)	Unknown
Microsoft.UI.Windowing.Core.dll!Content::WorkScheduler::DoOneCycleOfWork(void)	Unknown
Microsoft.UI.Windowing.Core.dll!Content::WorkScheduler::Dispatch(struct CFlat::Ref<bool>)	Unknown
Microsoft.UI.Windowing.Core.dll!EnterContextAndDispatchWork()	Unknown
Microsoft.UI.Windowing.Core.dll!Content::DispatchEntryCallback(void *,bool *)	Unknown
CoreMessagingXP.dll!CFlat::SehSafe::Execute<<lambda_c083b4bc627c9c35d0a8bae2e0cd5a75>>()	Unknown
CoreMessagingXP.dll!Microsoft::CoreUI::DispatchGroupBatchEnableHandler::ImportAdapter$(class CFlat::Box$1<struct CFlat::FunctionPointerAndUserData$1<long > > *,struct CFlat::Ref<bool>)	Unknown
CoreMessagingXP.dll!Microsoft::CoreUI::BatchEnabledDispatchGroup::Callback_OnDispatchCore(void)	Unknown
CoreMessagingXP.dll!Microsoft::CoreUI::DispatchGroup::Callback_OnDispatch(void)	Unknown
CoreMessagingXP.dll!Microsoft::CoreUI::Dispatch::Dispatcher::Callback_DispatchNextItem(class Microsoft::CoreUI::Dispatch::DispatchItem *)	Unknown
CoreMessagingXP.dll!Microsoft::CoreUI::Dispatch::Dispatcher::Callback_DispatchLoop(enum Microsoft::CoreUI::Dispatch::RunnablePriorityMask)	Unknown
CoreMessagingXP.dll!Microsoft::CoreUI::Dispatch::EventLoop::Callback_RunCoreLoop(enum Microsoft::CoreUI::Dispatch::RunMode)	Unknown
CoreMessagingXP.dll!Microsoft::CoreUI::Dispatch::UserAdapter::DrainCoreMessagingQueue(enum Microsoft::CoreUI::Dispatch::UserAdapter$UserPriority,void * *)	Unknown
CoreMessagingXP.dll!Microsoft::CoreUI::Dispatch::UserAdapter::OnUserDispatch(bool,enum Microsoft::CoreUI::Dispatch::UserAdapter$UserPriority,void * *)	Unknown
CoreMessagingXP.dll!Microsoft::CoreUI::Dispatch::UserAdapter::OnUserDispatchRaw(enum Microsoft::CoreUI::Dispatch::UserAdapter$UserPriority,bool,void * *)	Unknown
CoreMessagingXP.dll!Microsoft::CoreUI::Dispatch::UserAdapter::DoWork(struct HWND__ *,enum Microsoft::CoreUI::Dispatch::UserAdapter$UserPriority,bool)	Unknown
CoreMessagingXP.dll!Microsoft::CoreUI::Dispatch::UserAdapter::HandleDispatchNotifyMessage(struct HWND__ *,unsigned __int64,__int64)	Unknown
CoreMessagingXP.dll!Microsoft::CoreUI::Dispatch::UserAdapter::WindowProc(struct HWND__ *,unsigned int,unsigned __int64,__int64)	Unknown
user32.dll!UserCallWinProcCheckWow()	Unknown
user32.dll!DispatchMessageWorker()	Unknown
Microsoft.ui.xaml.dll!DirectUI::FrameworkApplication::RunDesktopWindowMessageLoop()	Unknown
Microsoft.ui.xaml.dll!DirectUI::FrameworkApplication::StartDesktop()	Unknown
Microsoft.ui.xaml.dll!DirectUI::FrameworkApplicationFactory::Start()	Unknown
[Managed to Native Transition]	
Microsoft.WinUI.dll!ABI.Microsoft.UI.Xaml.IApplicationStaticsMethods.Start(WinRT.IObjectReference _obj, Microsoft.UI.Xaml.ApplicationInitializationCallback callback)	Unknown
Microsoft.WinUI.dll!Microsoft.UI.Xaml.Application.Start(Microsoft.UI.Xaml.ApplicationInitializationCallback callback)	Unknown
HouseMoney.dll!HouseMoney.Program.Main(string[] args) Line 31	C#
[Native to Managed Transition]	
[Inline Frame] hostpolicy.dll!coreclr_t::execute_assembly(int) Line 109	C++
hostpolicy.dll!run_app_for_context(const hostpolicy_context_t & context, int argc, const wchar_t * * argv) Line 255	C++
hostpolicy.dll!run_app(const int argc, const wchar_t * * argv) Line 284	C++
hostpolicy.dll!corehost_main(const int argc, const wchar_t * * argv) Line 430	C++
hostfxr.dll!execute_app(const std::wstring & impl_dll_dir, corehost_init_t * init, const int argc, const wchar_t * * argv) Line 146	C++
hostfxr.dll!`anonymous namespace'::read_config_and_execute(const std::wstring & host_command, const host_startup_info_t & host_info, const std::wstring & app_candidate, const std::unordered_map<enum known_options,std::vector<std::wstring,std::allocator<std::wstring>>,known_options_hash,std::equal_to<enum known_options>,std::allocator<std::pair<enum known_options const ,std::vector<std::wstring,std::allocator<std::wstring>>>>> & opts, int new_argc, const wchar_t * * new_argv, host_mode_t mode, const bool is_sdk_command, wchar_t * out_buffer, int buffer_size, int * required_buffer_size) Line 533	C++
hostfxr.dll!fx_muxer_t::handle_exec_host_command(const std::wstring & host_command, const host_startup_info_t & host_info, const std::wstring & app_candidate, const std::unordered_map<enum known_options,std::vector<std::wstring,std::allocator<std::wstring>>,known_options_hash,std::equal_to<enum known_options>,std::allocator<std::pair<enum known_options const ,std::vector<std::wstring,std::allocator<std::wstring>>>>> & opts, int argc, const wchar_t * * argv, int argoff, host_mode_t mode, const bool is_sdk_command, wchar_t * result_buffer, int buffer_size, int * required_buffer_size) Line 1018	C++
hostfxr.dll!fx_muxer_t::execute(const std::wstring host_command, const int argc, const wchar_t * * argv, const host_startup_info_t & host_info, wchar_t * result_buffer, int buffer_size, int * required_buffer_size) Line 579	C++
hostfxr.dll!hostfxr_main_startupinfo(const int argc, const wchar_t * * argv, const wchar_t * host_path, const wchar_t * dotnet_root, const wchar_t * app_path) Line 61	C++
HouseMoney.exe!exe_start(const int argc, const wchar_t * * argv) Line 251	C++
HouseMoney.exe!wmain(const int argc, const wchar_t * * argv) Line 322	C++
[Inline Frame] HouseMoney.exe!invoke_main() Line 90	C++
HouseMoney.exe!__scrt_common_main_seh() Line 288	C++
kernel32.dll!BaseThreadInitThunk()	Unknown
ntdll.dll!RtlUserThreadStart()	Unknown

@driver1998
Copy link

driver1998 commented Apr 19, 2023

How about putting something in Content?

m_window.Content = new Grid();

Oh you already tried, sorry.

@bpulliam bpulliam transferred this issue from microsoft/WindowsAppSDK Apr 20, 2023
@bpulliam bpulliam added bug Something isn't working team-Rendering Issue for the Rendering team fixed-internally This bug has been fixed, and the fix will be shipped in the next version of WinUI 3. labels Apr 20, 2023
@bpulliam bpulliam added fixed-in-WinAppSDK1.3 and removed fixed-internally This bug has been fixed, and the fix will be shipped in the next version of WinUI 3. labels May 9, 2023
@bpulliam
Copy link
Contributor

bpulliam commented May 9, 2023

The fix for this issue is in 1.3.1 that is now available.

@bpulliam
Copy link
Contributor

1.3.1 = 1.3.230502000 (built May 2, 2023)

@Balkoth
Copy link
Author

Balkoth commented May 10, 2023

Crash is gone and content no longer needed, so this seems fixed to me 👍

@Balkoth Balkoth closed this as completed May 10, 2023
JasonWei512 added a commit to JasonWei512/EnergyStarX that referenced this issue May 10, 2023
No longer needed for Windows App SDK 1.3.230502000:
microsoft/microsoft-ui-xaml#8416 (comment)
@bpulliam bpulliam added this to the WinUI 3 in WinAppSDK 1.3 milestone May 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working team-Rendering Issue for the Rendering team
Projects
None yet
Development

No branches or pull requests

3 participants