×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    Regular Contributor
    Join Date
    Oct 2013
    Location
    Pennsauken, NJ, USA
    Posts
    121

    Unhappy DirectX WinRT component + Nokia Imaging SDK conflicting

    First, let me say that I'm pretty sure there's nothing wrong with the implementation of Nokia Imaging SDK I'm using (copied mostly from samples). However, my app uses a DirectX/C++ WinRT component that seems to be conflicting with Nokia Imaging.

    Without posting the entire solution, my app starts out with a plain Panorama-based xaml page in a C# application. You can then navigate to a second page that loads the WinRT component to fill a DrawingSurfaceBackgroundGrid -or- you can go to page that simply loads the Nokia Imaging SDK to draw on a canvas.

    The page that uses Nokia Imaging SDK works fine. I can navigate there and my images are rendered correctly. However, if I first navigate to the DirectX page (which loads and functions correctly), then go back and navigate to the Nokia Imaging page, then there are problems. The image never loads and I don't see any errors (managed or native).

    I believe that I am not shutting down the DirectX objects correctly when I navigate back from my DirectX page. The problem is I am not sure how to do it properly. Every single one of my interfaces are wrapped in a ComPtr. I am led to believe that when these go out of scope, i.e. when the WinRT Component object is set to NULL, that they would automatically release. What confuses me is that I can exit out of the DirectX page and then re-enter it to draw a different molecule (I'm drawing 3d molecules) and it will work fine. It does not seem to be leaking any memory.

    Does anyone have any suggestions? What I really need is a good tutorial that shows how to cleanup directx using ComPtrs. I'd be happy to go into more detail if anyone wants to take a stab at this. Thanks in advance!
    Last edited by leemcpherson; 2014-02-18 at 05:45. Reason: making it a bit clearer

  2. #2
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    526

    Re: DirectX WinRT component + Nokia Imaging SDK conflicting

    I unfortunately have no experience with DirectX on WinRT but what exactlly is the behavior of the ImagingSDK page. Can you debug your Imaging SDK code and step through it in the Debugger? You could try to render the image to the Picture Library in addition to the WriteableBitmap you're currently using to display the image. That way we'd know wether really the processing using the SDK is affected by the DirectX component or if it's merely an issue with displaying it afterwards.

  3. #3
    Regular Contributor
    Join Date
    Nov 2011
    Location
    la bouexiere, france
    Posts
    476

    Re: DirectX WinRT component + Nokia Imaging SDK conflicting

    I thinks it more a problem with navigation than Imaging SDK.
    WHat do you do when you navigate to the ImagingSDK and you come back?
    Windows 8, Windows phone 8 or Nokia Asha developer? Go to DVLUP

  4. #4
    Regular Contributor
    Join Date
    Oct 2013
    Location
    Pennsauken, NJ, USA
    Posts
    121

    Re: DirectX WinRT component + Nokia Imaging SDK conflicting

    Quote Originally Posted by SB Dev View Post
    I unfortunately have no experience with DirectX on WinRT but what exactlly is the behavior of the ImagingSDK page. Can you debug your Imaging SDK code and step through it in the Debugger? You could try to render the image to the Picture Library in addition to the WriteableBitmap you're currently using to display the image. That way we'd know wether really the processing using the SDK is affected by the DirectX component or if it's merely an issue with displaying it afterwards.
    Again, it only fails when I have previously loaded my component that uses DirectX. This is what happens with the Nokia Imaging methods:

    StreamImageSource is created successfully from a stream from the StorageFile. Calling GetInfoAsync() on the StreamImageSource yields the correct image dimensions (2457x4096). I'm using pretty much exactly the same class from a sample in the wiki ("Method2Filter") for drawing jpegs and manipulating them using panning and pinching. So the next step is to generate a low-resolution image for full screen display. The image is broken up into 16 blocks and a WriteableBitmapRenderer is created for each one. The RenderAsync() method is successful for only the first block... then it never returns on the second block in the loop.


    Quote Originally Posted by yan_ View Post
    I thinks it more a problem with navigation than Imaging SDK.
    WHat do you do when you navigate to the ImagingSDK and you come back?
    I'm using pretty basic navigation:

    Code:
    var frame = Application.Current.RootVisual as PhoneApplicationFrame;
    frame.Navigate(new Uri(string.Format("/ImageViewPage.xaml?file={0}", FileName), UriKind.Relative));
    Since I'm pretty sure there's a problem with my WinRT component, this is what I'm currently doing with it on the c# side when I navigate away from that page.

    Code:
    protected override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e)
            {
                if (m_d3dBackground != null)
                    m_d3dBackground.statusEvent -= m_d3dBackground_statusEvent;
    
                  m_d3dBackground = null;
    
                base.OnNavigatedFrom(e);
            }
    Last edited by leemcpherson; 2014-02-18 at 15:41.

  5. #5
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    526

    Re: DirectX WinRT component + Nokia Imaging SDK conflicting

    Curious - if you only did your first RenderAsync call and then tried to run something else asynchronously - does that work? Otherwise this might be an issue with queuing the Task to be executed.

  6. #6
    Regular Contributor
    Join Date
    Nov 2011
    Location
    la bouexiere, france
    Posts
    476

    Re: DirectX WinRT component + Nokia Imaging SDK conflicting

    Quote Originally Posted by leemcpherson View Post
    StreamImageSource is created successfully from a stream from the StorageFile. Calling GetInfoAsync() on the StreamImageSource yields the correct image dimensions (2457x4096). I'm using pretty much exactly the same class from a sample in the wiki ("Method2Filter") for drawing jpegs and manipulating them using panning and pinching. So the next step is to generate a low-resolution image for full screen display. The image is broken up into 16 blocks and a WriteableBitmapRenderer is created for each one. The RenderAsync() method is successful for only the first block... then it never returns on the second block in the loop.
    Can you show the code? do you use Task.waitAll or something like that?

    Quote Originally Posted by leemcpherson View Post
    I'm using pretty basic navigation
    what do you do in DrawingSurface_Loaded ?
    Windows 8, Windows phone 8 or Nokia Asha developer? Go to DVLUP

  7. #7
    Regular Contributor
    Join Date
    Oct 2013
    Location
    Pennsauken, NJ, USA
    Posts
    121

    Re: DirectX WinRT component + Nokia Imaging SDK conflicting

    Here is how the DrawingSurfaceBackgroundGrid is setup. Since every DirectX/Xaml wp8 code example I've seen uses this control as the main screen, I'm not exactly sure of the correct way to unload it. I've tried setting the BackgroundContentProvider and the BackgroundManipulationHandler to null, but that doesn't seem to help. I've noticed that in the WinRT component that gets generated from the template, there is a Disconnect method that is empty. I don't know how that gets called, because there is no other reference to it.

    Code:
    private async void DrawingSurfaceBackground_Loaded(object sender, RoutedEventArgs e)
            {
                if (m_d3dBackground == null)
                {
                    m_d3dBackground = new Direct3DBackground();
                    Debug.WriteLine("Created Direct3DBackground object");
    
                    // Register event handler that displays component status messages in XAML controls
                    m_d3dBackground.statusEvent += m_d3dBackground_statusEvent;
    
                    //this needs to be here because the async part makes this loaded event sometimes happen before the StorageFile is finished loading in the onNavigatedTo method
                    m_storageFile = await ApplicationData.Current.LocalFolder.GetFileAsync(m_fileName);
              
                    // Load the file into the rendering processor
                    m_d3dBackground.SetStorageFile(m_storageFile);
                    Debug.WriteLine("Set storagefile property");
    
                    // Set window bounds in dips
                    m_d3dBackground.WindowBounds = new Windows.Foundation.Size(
                        (float)Application.Current.Host.Content.ActualWidth,
                        (float)Application.Current.Host.Content.ActualHeight
                        );
    
                    // Set native resolution in pixels
                    m_d3dBackground.NativeResolution = new Windows.Foundation.Size(
                        (float)Math.Floor(Application.Current.Host.Content.ActualWidth * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f),
                        (float)Math.Floor(Application.Current.Host.Content.ActualHeight * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f)
                        );
    
                    // Set render resolution to the full native resolution
                    m_d3dBackground.RenderResolution = m_d3dBackground.NativeResolution;
    
                    // Hook-up native component to DrawingSurfaceBackgroundGrid
                    DrawingSurfaceBackground.SetBackgroundContentProvider(m_d3dBackground.CreateContentProvider());
                    DrawingSurfaceBackground.SetBackgroundManipulationHandler(m_d3dBackground);
                }
            }
    The Nokia Imaging page is exactly like what is in the sample here:
    http://developer.nokia.com/community..._Windows_Phone

    I'm not using any Task.Run or Task.wait calls in any of the pages: panorama main page, directx page, or nokia imaging page. There are plenty of those in the C++ WinRT component though.

  8. #8
    Regular Contributor
    Join Date
    Nov 2011
    Location
    la bouexiere, france
    Posts
    476

    Re: DirectX WinRT component + Nokia Imaging SDK conflicting

    Visual Studio sample crash when you add navigation between page...
    When you comeback to the directX page DrawingSurfaceBackground_Loaded is called again. So you need to reinitialize several parameters. This is my DrawingSurfaceBackground_Loaded function :
    Code:
    private void DrawingSurface_Loaded(object sender, RoutedEventArgs e)
    {
    
        // Set window bounds in dips
        m_d3dInterop.WindowBounds = new Windows.Foundation.Size(
            (float)DrawingSurface.ActualWidth,
            (float)DrawingSurface.ActualHeight
            );
    
        // Set native resolution in pixels
        m_d3dInterop.NativeResolution = new Windows.Foundation.Size(
            (float)Math.Floor(DrawingSurface.ActualWidth * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f),
            (float)Math.Floor(DrawingSurface.ActualHeight * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f)
            );
    
        // Set render resolution to the full native resolution
        m_d3dInterop.RenderResolution = m_d3dInterop.NativeResolution;
    
        // Hook-up native component to DrawingSurface
        if (m_contentProvider == null)
        {
            m_contentProvider = m_d3dInterop.CreateContentProvider();
        }
        DrawingSurface.SetContentProvider(m_contentProvider);
    
        DrawingSurface.SetManipulationHandler(m_d3dInterop);
    }
    m_d3dInterop.CreateContentProvider(); should be call only once.



    Have you the lock with the sample here : http://developer.nokia.com/community...Windows_Phone?
    If yes, can you give a picture?
    Windows 8, Windows phone 8 or Nokia Asha developer? Go to DVLUP

  9. #9
    Regular Contributor
    Join Date
    Oct 2013
    Location
    Pennsauken, NJ, USA
    Posts
    121

    Re: DirectX WinRT component + Nokia Imaging SDK conflicting

    Thanks everyone so far... I went to read about the CreateContentProvider function at this link and I realized that I am using an old template for the Direct3D XAML interop. Mine did not have GetTexture() and a few other things were different. So, I'm going to rebuild everything using the newer template and see if that helps with my problem.

    ***** Nevermind all that. I am tired and chose the template with a DrawingSurface control... the templates haven't changed. I think I'm going to switch to using the DrawingSurface only and see if that helps despite the slight decrease in FPS. The DrawingSurfaceBackgroundGrid seems like it was meant to be initialized once and stay in the background permanently.
    Last edited by leemcpherson; 2014-02-19 at 05:33. Reason: tired!

  10. #10
    Regular Contributor
    Join Date
    Nov 2011
    Location
    la bouexiere, france
    Posts
    476

    Re: DirectX WinRT component + Nokia Imaging SDK conflicting

    DrawingSurface and DrawingSurfaceBackgroundGrid are really similare and performance are normally very similare.

    Visual studio sample crash if you add a navigation. I'm not sure they have been corrected. If i remember correctly, it's just the recall of CreateContentProvider() when you come back to the Direct3D page.
    Windows 8, Windows phone 8 or Nokia Asha developer? Go to DVLUP

  11. #11
    Regular Contributor
    Join Date
    Oct 2013
    Location
    Pennsauken, NJ, USA
    Posts
    121

    Re: DirectX WinRT component + Nokia Imaging SDK conflicting

    Quote Originally Posted by yan_ View Post
    DrawingSurface and DrawingSurfaceBackgroundGrid are really similare and performance are normally very similare.

    Visual studio sample crash if you add a navigation. I'm not sure they have been corrected. If i remember correctly, it's just the recall of CreateContentProvider() when you come back to the Direct3D page.
    I'm going to make that change, but I actually wasn't having any problems with the DirectX page. I can load it as many times as I want and there is no crash. It's the Nokia Imaging that stalls after using the DirectX page.

    In any case, I finished moving all my code to a XAML/DirectX template that uses DrawingSurface (instead of a DirectX/XAML template that uses DrawingSurfaceBackgroundGrid)... and I get the same effect. Nokia Imaging stops working if I open the DirectX page.

    However, I've found that there is a difference between DrawingSurface and DrawingSurfaceBackgroundGrid. Maybe it was just a coincidence that my bad code worked, but the DrawingSurfaceBackgroundGrid was more tolerant of immediate d3dContext calls from other threads... it worked without me having to synchronize anything. The plain DrawingSurface control stopped whenever the immediate d3dContext was used from a different thread. Anyways, I haven't seen a big difference in FPS for my application, so I might as well stick with the DrawingSurface control.

    I'm going to keep working at releasing resources in the DirectX component and see if I can fix the Nokia Imaging problem... sometime tomorrow.
    Last edited by leemcpherson; 2014-02-20 at 02:52.

  12. #12
    Regular Contributor
    Join Date
    Oct 2013
    Location
    Pennsauken, NJ, USA
    Posts
    121

    Re: DirectX WinRT component + Nokia Imaging SDK conflicting

    I decided to make a quick movie to show exactly what was happening. (My shaders do not work on the emulator, so I had to use my actual device.)

    The problem with Nokia Imaging did not happen! To my shame, I never actually tested the problem while not actually connected to the debugger. So there seems to be a small problem with the debugger... maybe it's the debugging flag used in creating the d3dDevice. In any case, I can work around that.

    So, here's the video anyways. Thanks for all your help!

    http://1drv.ms/1d2gPhJ

  13. #13
    Regular Contributor
    Join Date
    Nov 2011
    Location
    la bouexiere, france
    Posts
    476

    Re: DirectX WinRT component + Nokia Imaging SDK conflicting

    Quote Originally Posted by leemcpherson View Post
    I decided to make a quick movie to show exactly what was happening. (My shaders do not work on the emulator, so I had to use my actual device.)

    The problem with Nokia Imaging did not happen! To my shame, I never actually tested the problem while not actually connected to the debugger. So there seems to be a small problem with the debugger... maybe it's the debugging flag used in creating the d3dDevice. In any case, I can work around that.
    I'm happy to see my control usefull


    Quote Originally Posted by leemcpherson View Post
    What is the problems?

    Very interesting app
    Windows 8, Windows phone 8 or Nokia Asha developer? Go to DVLUP

  14. #14
    Regular Contributor
    Join Date
    Oct 2013
    Location
    Pennsauken, NJ, USA
    Posts
    121

    Re: DirectX WinRT component + Nokia Imaging SDK conflicting

    Quote Originally Posted by yan_ View Post
    I'm happy to see my control usefull
    Merci! It's very helpful.

    No problems now. I made the video before I realized it was fixed, so I just posted it for fun.

  15. #15
    Regular Contributor
    Join Date
    Nov 2011
    Location
    la bouexiere, france
    Posts
    476

    Re: DirectX WinRT component + Nokia Imaging SDK conflicting

    Quote Originally Posted by leemcpherson View Post
    No problems now. I made the video before I realized it was fixed, so I just posted it for fun.
    Cool. Good luck for your app
    Windows 8, Windows phone 8 or Nokia Asha developer? Go to DVLUP

Similar Threads

  1. how to synchronize WinRT render and directX render
    By xlazom00 in forum Windows Phone General
    Replies: 3
    Last Post: 2013-03-08, 13:06
  2. DirectX speeding up CreateTexture2d
    By hdxpete in forum Windows Phone General
    Replies: 6
    Last Post: 2013-01-26, 01:27
  3. conflicting application show item come on nokia 7610 supernova on ovi app
    By itssanchit in forum General Development Questions
    Replies: 1
    Last Post: 2010-01-30, 08:35
  4. Uninstalled Motorola PhoneTools conflicting with Nokia PC Suite 6.70.22
    By JuniorHacksaw in forum PC Suite API and PC Connectivity SDK
    Replies: 1
    Last Post: 2006-04-30, 07:59
  5. Uninstalled Motorola PhoneTools conflicting with Nokia PC Suite 6.70.22
    By JuniorHacksaw in forum Series 40 & S60 Platform Feedback Archive
    Replies: 1
    Last Post: 2006-04-30, 07:59

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×