Avalonia icon indicating copy to clipboard operation
Avalonia copied to clipboard

Unable to create child window for native control host

Open rdeusser opened this issue 2 months ago • 7 comments

Describe the bug

Basically #8609, except the solution already exists in the project. I’m using Ryujinx and I only get this exception when I enable mods. It’s confusing because it seems like the issue in #8609 has a singular cause, but it appears there’s other ways to make it crop up. Is there a definitive cause for this exception? The stacktrace is incredibly unhelpful because it doesn’t show me anything in Ryujinx outside of ‘BuildAvaloniaApp’. I can post a stacktrace later. I’m on mobile at the moment.

To Reproduce

  • Download latest Ryujinx
  • Follow their guide on dumping a game you own legitimately (in my case Tears of the Kingdom v1.2.1)
  • Find a v1.2.1 mod and enable it
  • Start game and it should crash with the exception in the logs Ryujinx writes to disk

Expected behavior

Potentially a crash that has nothing to do with Avalonia, otherwise a working game.

Avalonia version

11.0.10

OS

Windows

Additional context

I’ll add more here later when I can get back to my computer.

rdeusser avatar Apr 13 '24 16:04 rdeusser

We need a proper minimal repro to even try to help with this issue. We don't have dev capacity to investigate Ryujinx source code and repro this issue with a dumped (legitimately) game images.

maxkatz6 avatar Apr 13 '24 21:04 maxkatz6

I can at least provide a stack trace for this issue for now, since a person with this issue uploaded a log in our support channels.

Stack trace
Unhandled exception caught: System.InvalidOperationException: Unable to create child window for native control host. Application manifest with supported OS list might be required.
   at Avalonia.Win32.Win32NativeControlHost.DumbWindow..ctor(Boolean , Nullable`1 )
   at Avalonia.Win32.Win32NativeControlHost.CreateNewAttachment(Func`2)
   at Avalonia.Controls.NativeControlHost.UpdateHost()
   at Avalonia.Controls.NativeControlHost.OnAttachedToVisualTree(VisualTreeAttachmentEventArgs)
   at Avalonia.Visual.OnAttachedToVisualTreeCore(VisualTreeAttachmentEventArgs)
   at Avalonia.Layout.Layoutable.OnAttachedToVisualTreeCore(VisualTreeAttachmentEventArgs)
   at Avalonia.Input.InputElement.OnAttachedToVisualTreeCore(VisualTreeAttachmentEventArgs)
   at Avalonia.Controls.Control.OnAttachedToVisualTreeCore(VisualTreeAttachmentEventArgs)
   at Avalonia.Visual.SetVisualParent(Visual)
   at Avalonia.Visual.SetVisualParent(IList, Visual )
   at Avalonia.Visual.VisualChildrenChanged(Object sender, NotifyCollectionChangedEventArgs e)
   at Avalonia.Collections.AvaloniaList`1.Add(T)
   at Avalonia.Controls.Presenters.ContentPresenter.UpdateChild(Object)
   at Avalonia.Controls.Presenters.ContentPresenter.UpdateChild()
   at Avalonia.Controls.Presenters.ContentPresenter.ApplyTemplate()
   at Avalonia.Layout.Layoutable.MeasureCore(Size)
   at Avalonia.Layout.Layoutable.Measure(Size)
   at Avalonia.Layout.Layoutable.MeasureOverride(Size)
   at Avalonia.Layout.Layoutable.MeasureCore(Size)
   at Avalonia.Layout.Layoutable.Measure(Size)
   at Avalonia.Layout.LayoutHelper.MeasureChild(Layoutable, Size, Thickness, Thickness)
   at Avalonia.Controls.Presenters.ContentPresenter.MeasureOverride(Size)
   at Avalonia.Layout.Layoutable.MeasureCore(Size)
   at Avalonia.Layout.Layoutable.Measure(Size)
   at Avalonia.Layout.LayoutManager.Measure(Layoutable)
   at Avalonia.Layout.LayoutManager.ExecuteMeasurePass()
   at Avalonia.Layout.LayoutManager.InnerLayoutPass()
   at Avalonia.Layout.LayoutManager.ExecuteLayoutPass()
   at Avalonia.Layout.LayoutManager.ExecuteQueuedLayoutPass()
   at Avalonia.Media.MediaContext.FireInvokeOnRenderCallbacks()
   at Avalonia.Media.MediaContext.RenderCore()
   at Avalonia.Media.MediaContext.Render()
   at Avalonia.Threading.DispatcherOperation.InvokeCore()
   at Avalonia.Threading.DispatcherOperation.Execute()
   at Avalonia.Threading.Dispatcher.ExecuteJob(DispatcherOperation)
   at Avalonia.Threading.Dispatcher.ExecuteJobsCore(Boolean)
   at Avalonia.Threading.Dispatcher.Signaled()
   at Avalonia.Win32.Win32Platform.WndProc(IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam)
   at Avalonia.Win32.Interop.UnmanagedMethods.DispatchMessage(MSG&)
   at Avalonia.Win32.Win32DispatcherImpl.RunLoop(CancellationToken)
   at Avalonia.Threading.DispatcherFrame.Run(IControlledDispatcherImpl)
   at Avalonia.Threading.Dispatcher.PushFrame(DispatcherFrame)
   at Avalonia.Threading.Dispatcher.MainLoop(CancellationToken)
   at Avalonia.Controls.ApplicationLifetimes.ClassicDesktopStyleApplicationLifetime.Start(String[])
   at Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime(AppBuilder, String[], Action`1 )
   at Ryujinx.Ava.Program.Main(String[] args) in D:\a\Ryujinx\Ryujinx\src\Ryujinx\Program.cs:line 52

I'm currently investigating this myself, so I'll follow up if I figure out more about this issue.

I feel like the error message should maybe include that Handle is a null pointer? https://github.com/AvaloniaUI/Avalonia/blob/76a1c70758884abcebc9e3665aa08290a841efa4/src/Windows/Avalonia.Win32/Win32NativeControlHost.cs#L98-L99

TSRBerry avatar Apr 28 '24 20:04 TSRBerry

Since CreateWindowExW sets an error code, it would be nice if the exceptions could also include it with the associated error message.

See Marshal.GetLastPInvokeError() and Marshal.GetLastPInvokeErrorMessage()

TSRBerry avatar Apr 28 '24 21:04 TSRBerry

@TSRBerry maybe you can file a PR to improve the error message as you seem to know where to do it

timunie avatar Apr 29 '24 04:04 timunie

@TSRBerry you are most likely missing app.manifest file, as it's mentioned in the error message.

maxkatz6 avatar Apr 29 '24 21:04 maxkatz6

Well no, see the issue description and the app.manifest file here.

TSRBerry avatar Apr 30 '24 00:04 TSRBerry

In this case, can't help much. GetLastPInvokeErrorMessage can be an inner exception, yes.

maxkatz6 avatar Apr 30 '24 00:04 maxkatz6