AvaloniaUI / Avalonia

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology
https://avaloniaui.net
MIT License
25.73k stars 2.22k forks source link

Direct2D backend does not work on some systems #869

Closed KvanTTT closed 6 years ago

KvanTTT commented 7 years ago

I got the following window with empty content: avalonia control gallery.

Maybe this issue related to shcore.dll library.

kekekeks commented 7 years ago

Try with Skia backend. It might be somehow related to Direct2D

grokys commented 7 years ago

Could you make sure this update is installed? https://msdn.microsoft.com/en-us/library/windows/desktop/jj863687(v=vs.85).aspx

KvanTTT commented 7 years ago

Yes, this update (KB2670838) installed on my computer.

amerkoleci commented 7 years ago

Strange, as from msdn Direct2D works from windows 7, better check twice, maybe you re using some feature available in win8 only?

KvanTTT commented 7 years ago

Maybe Avalonia uses DirectComposition features as @kekekeks said? It's available since Win 8.1.

kekekeks commented 7 years ago

Might be related to changes introduced by this PR: https://github.com/AvaloniaUI/Avalonia/pull/850

https://github.com/AvaloniaUI/Avalonia/pull/850/commits/f44468a3ab6f2abb0d1cb5250ebe835b952dcaa2#diff-0c90be92f9ea152473fef6304fadb3e3R47 It now requires DirectX 12, so that might be failing

kekekeks commented 7 years ago

It also uses a couple of DirectX 11 calls. I'm not sure that it's the right behavior from compatibility point of view.

kekekeks commented 7 years ago

https://i.imgur.com/Uht4He4.png - Exception from static constructor

grokys commented 7 years ago

I assume that error is being thrown by this line?

https://github.com/AvaloniaUI/Avalonia/blob/master/src/Windows/Avalonia.Direct2D1/Direct2D1Platform.cs#L61

kekekeks commented 7 years ago

Not sure, screenshot was taken not from my machine

kekekeks commented 7 years ago

According to the stack trace it should be this line: https://github.com/AvaloniaUI/Avalonia/blob/master/src/Windows/Avalonia.Direct2D1/Direct2D1Platform.cs#L36

amerkoleci commented 7 years ago

Probably its necessary to check for debug layer support before enable debug features for DirectX backend

kekekeks commented 7 years ago

http://stackoverflow.com/questions/28242509/d2d1createfactory-fails-if-d2d1-debug-level-information-is-set

kekekeks commented 7 years ago

@OronDF343 could you please provide a stacktrace of your DXGI_ERROR_INVALID_CALL?

OronDF343 commented 7 years ago

This one happens with GTK and Direct2D1:

Marshaling expose_event signal
Exception in Gtk# callback delegate
  Note: Applications can use GLib.ExceptionManager.UnhandledException to handle the exception.
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> SharpDX.SharpDXException: HRESULT: [0x887A0001], Module: [SharpDX.DXGI], ApiCode: [DXGI_ERROR_INVALID_CALL/InvalidCall], Message: Unknown
   at SharpDX.Result.CheckError()
   at SharpDX.DXGI.Factory2.CreateSwapChainForHwnd(ComObject deviceRef, IntPtr hWnd, SwapChainDescription1& descRef, Nullable`1 fullscreenDescRef, Output restrictToOutputRef, SwapChain1 swapChainOut)
   at Avalonia.Direct2D1.HwndRenderTarget.CreateSwapChain(Factory2 dxgiFactory, SwapChainDescription1 swapChainDesc)
   at Avalonia.Direct2D1.SwapChainRenderTarget.CreateSwapChain()
   at Avalonia.Direct2D1.SwapChainRenderTarget.CreateDrawingContext()
   at Avalonia.Rendering.RendererMixin.Render(IRenderTarget renderTarget, IVisual visual)
   at Avalonia.Rendering.Renderer.Render(Rect rect)
   at Avalonia.Gtk.TopLevelImpl.OnExposeEvent(Object o, ExposeEventArgs args)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Delegate.DynamicInvokeImpl(Object[] args)
   at GLib.Signal.ClosureInvokedCB(Object o, ClosureInvokedArgs args)
   at GLib.SignalClosure.Invoke(ClosureInvokedArgs args)
   at GLib.SignalClosure.MarshalCallback(IntPtr raw_closure, IntPtr return_val, UInt32 n_param_vals, IntPtr param_values, IntPtr invocation_hint, IntPtr marshal_data)
   at GLib.ExceptionManager.RaiseUnhandledException(Exception e, Boolean is_terminal)
   at GLib.SignalClosure.MarshalCallback(IntPtr raw_closure, IntPtr return_val, UInt32 n_param_vals, IntPtr param_values, IntPtr invocation_hint, IntPtr marshal_data)
   at Gtk.Application.gtk_maThe program '[8032] ICEPlayer.UI.Windows.exe' has exited with code 1 (0x1).
in_iteration()
   at Avalonia.Gtk.GtkPlatform.RunLoop(CancellationToken cancellationToken)
   at Avalonia.Threading.Dispatcher.MainLoop(CancellationToken cancellationToken)
   at Avalonia.Application.Run(ICloseable closable)
   at Avalonia.Controls.AppBuilderBase`1.Start[TMainWindow](Func`1 dataContextProvider)
   at ICEPlayer.UI.Windows.Program.Main(String[] args) in C:\Users\Oron\OneDrive\ProjectICE\ICEPlayer\ICEPlayer.UI.Windows\Program.cs:line 21

On Win32 I just get a blank white window as above. I'm no longer able to reproduce the error that I got with an empty class inheriting from Window on Win32.

andrewst commented 7 years ago

I think issue this line https://github.com/AvaloniaUI/Avalonia/pull/850/files#diff-d5d54e96d54f8703b8a8d99483dc5b38R103 SwapEffect.FlipSequential start support windows 8. https://msdn.microsoft.com/en-us/library/windows/desktop/bb173077(v=vs.85).aspx