locked
ISurfaceImageSourceNativeWithD2D ComException 0x802B0020 with VirtualSurfaceImageSource

    Question

  • Hi,

    in my project on C# I use VirtualSurfaceImageSource and ComWrappers to render some data. VSIS is casted to ISurfaceImageSourceNativeWithD2D. First rendering of each VSIS works fine, but after second rendering of VSIS I have a ComException with HResult: 0x802B0020, when SISN.BeginDraw is called.

    It was tested on Win 8.1 and VS2013 pro. Here link on sample Project

    Steps to reproduce:

    1) Open project and launch app

    2) In FlipView go to page 6 and then to page 1



    Wednesday, November 20, 2013 9:33 AM

Answers

All replies

  • Hi Mikhail Maksyuta,

    Welcome here!

    I have reproduced your issue and found the reason, please look at the code you written:

     while(true) {
                    if (TaskList.Count != 0)
                    {
                        BackgroundRenderTaskInfo taskInfo = TaskList[0];
                        TaskList.RemoveAt(0);
    
                        ISurfaceImageSourceNativeWithD2D threadsSurface = taskInfo.SurfaceImageSource;
    
                        IDXGISurface surface = null;
                        RECT originalRect = taskInfo.SourceRect;
                        POINT offset = new POINT();
                        Guid guid = new Guid(DirectX.IIDS.IDXGISurface);
                        await uiDispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                        {
                            POINT offset1;
                            threadsSurface.BeginDraw(ref originalRect, ref guid, out surface, out offset1);
    
                            //threadsSurface.BeginDraw(originalRect, out surface, ref offset);
                            offset = offset1;
                        });
    
                        await uiDispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                        {
                            //threadsSurface.SuspendDraw();
                            threadsSurface.EndDraw();
                        });
    
                        Marshal.ReleaseComObject(surface);
                    }
                                }

    When I set a breakpoint, I find it will go into a infinite loop while TaskList.Count==0, and the error is display.

    Just add "else return;" will fix the issue.

    Like this:

    if (TaskList.Count != 0) { BackgroundRenderTaskInfo taskInfo = TaskList[0]; TaskList.RemoveAt(0); ISurfaceImageSourceNativeWithD2D threadsSurface = taskInfo.SurfaceImageSource; IDXGISurface surface = null; RECT originalRect = taskInfo.SourceRect; POINT offset = new POINT(); Guid guid = new Guid(DirectX.IIDS.IDXGISurface); await uiDispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { POINT offset1; threadsSurface.BeginDraw(ref originalRect, ref guid, out surface, out offset1); //threadsSurface.BeginDraw(originalRect, out surface, ref offset); offset = offset1; }); await uiDispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { //threadsSurface.SuspendDraw(); threadsSurface.EndDraw(); }); Marshal.ReleaseComObject(surface); } else return; }

    Hope it is helpful! :)

    Regards!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Thursday, November 21, 2013 7:34 AM
    Moderator

  • When I set a breakpoint, I find it will go into a infinite loop while TaskList.Count==0, and the error is display.

    Just add "else return;" will fix the issue.

    Here is renderer for project above without this loop. Steps to reproduce still the same:

    1) Open project and launch app
    2) In FlipView go to page 6 and then to page 1

    FYI: If we use SurfaceImageSource instead of VirtualSurfaceImageSource, then this sample works fine (with\without infinite loop).

    Thursday, November 21, 2013 12:46 PM
  • Hi Mikhail Maksyuta,

    If you want to have a look at the difference between VirtualSurfaceImageSource and SurfaceImageSource , this article fits for you:

    http://msdn.microsoft.com/en-us/library/windows/apps/hh825871.aspx

    Just select with VirtualSurfaceImageSource | SurfaceImageSource  on selected panel(ctr+f).

    Regards!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Friday, November 22, 2013 1:42 AM
    Moderator
  • Hi Mikhail Maksyuta,

    If you want to have a look at the difference between VirtualSurfaceImageSource and SurfaceImageSource , this article fits for you:

    http://msdn.microsoft.com/en-us/library/windows/apps/hh825871.aspx

    Just select with VirtualSurfaceImageSource | SurfaceImageSource  on selected panel(ctr+f).

    Regards!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    I know the difference between them. In real project I use VirtualSurfceImageSource and IVirtualSurfaceImageSouceNative.RegisterForUpdateNeeded to render data.

    I want to uses ISurfaceImageSourceNativeWithD2D interface for rendering, because it allows to render from background threads. Here is info from MSDN about ISurfaceImageSourceNativeWithD2D:

    The ISurfaceImageSourceNativeWithD2D interface enables drawing to a SurfaceImageSource or VirtualSurfaceImageSource from one or more background threads, which allows high-performance DirectX rendering off the UI thread.

    But when VirtualSurfaceImageSource is casted to IVirtualSurfaceImageSourceNativeWithD2D, I get ComException with HResult: 0x802B0020 on second rendering of surface, when method ISurfaceImageSourceNativeWithD2D.BeginDraw is called.



    Friday, November 22, 2013 6:16 AM
  • Hi Mikhail Maksyuta,

    Sorry for my careless.

    As this is the same issue which  you have  posted on:

    http://social.msdn.microsoft.com/Forums/en-US/34393360-9d63-45be-a16e-c97a4ad4154c/isurfaceimagesourcenativewithd2d-comexception-efail-in-background-thread?forum=wingameswithdirectx

    So, I will close it, and if you still have anywhere unclear, please feel free let me know!

    Regards!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, November 28, 2013 2:56 AM
    Moderator