Exception when turning off/on tv display on client (1 Viewer)

smadger

Portal Member
October 12, 2006
17
2
Home Country
Ireland Ireland
TV-Server Version: RC4
MediaPortal Version: RC4
MediaPortal Skin: Blue3Wide
Windows Version: XP SP3
CPU Type: Core 2 Duo
HDD: 80Gb
Memory: 1Gb
Motherboard: Apple mac mini
Video Card: Intel GMA 950
Video Card Driver:
Sound Card:
Sound Card AC3:
Sound Card Driver:
1. TV Card:
1. TV Card Type:
1. TV Card Driver:
2. TV Card:
2. TV Card Type:
2. TV Card Driver:
3. TV Card:
3. TV Card Type:
3. TV Card Driver:
4. TV Card:
4. TV Card Type:
4. TV Card Driver:
MPEG2 Video Codec: MPV
MPEG2 Audio Codec: MPA
h.264 Video Codec: CoreAVC
Satelite/CableTV Provider:
HTPC Case:
Cooling:
Power Supply:
Remote:
TV: Samsung LCD
TV - HTPC Connection: DVI-HDMI dongle

Hi,

While watching TV on a client (mac mini) connected to an lcd tv over hdmi, sometimes when I power off the lcd (but not the pc) without stopping mediaportal's tv plugin, the following exception appears on a black screen when the lcd is power back on:

An exception has occurred. Mediaportal has to be closed

System.NullReferenceException: Object reference not set to an instance of an object
at Mediaportal.D3DApp.RecoverDevice()
at Mediaportal.D3DApp.Render3DEnvironment()
at Mediaportal.D3DApp.FullRender()

Mediaportal needs to be restarted to recover.

This doesn't happen all the time. If I try to reproduce it, the system works fine and mediaportal recognises the display has be switched off and stops its tv client. I suspect that it only happens if viewing tv for quite a while.

Something similar used to happen on older releases, but I never got the exception window before - just a black screen.

Logs attached

P.S. Other that that RC4 is really cool!!!
 

smadger

Portal Member
October 12, 2006
17
2
Home Country
Ireland Ireland
Updated graphics driver to latest version. Didn't make any difference though :(
 

Paranoid Delusion

Moderation Manager
  • Premium Supporter
  • June 13, 2005
    13,062
    2,978
    Cheshire
    Home Country
    United Kingdom United Kingdom
    It looks like the driver is disconnecting, which gives feedback that D3D has failed (no output), have tried to get this too fail, with my Nvidia (dvi-hdmi), but it won't, I know there is a major difference between pc hdmi output and "normal" hdmi, that the pc version cannot totally emulate.
     

    smadger

    Portal Member
    October 12, 2006
    17
    2
    Home Country
    Ireland Ireland
    Thanks for the feedback.

    I had a look in the code. Didn't find the error as such but I found this in RecoverDevice() in d3dapp.cs:

    .....
    // Reset the device and resize it
    Log.Warn("d3dapp: Resetting DX9 device");
    try
    {
    // For Bav: reset fails with invalid call if we do not clean up all resources
    GUITextureManager.CleanupThumbs();
    GUITextureManager.Dispose();
    GUIFontManager.Dispose();

    // GUIGraphicsContext.DX9Device.EvictManagedResources();

    GUIGraphicsContext.DX9Device.Reset(GUIGraphicsContext.DX9Device.PresentationParameters);
    m_bNeedReset = false;
    } catch (Exception ex)
    {
    Log.Error("d3dapp: Reset failed - {0}/{1}", ex.Message);
    GUIGraphicsContext.DX9Device.DeviceLost -= new System.EventHandler(this.OnDeviceLost);
    GUIGraphicsContext.DX9Device.DeviceReset -= new EventHandler(this.OnDeviceReset);
    InitializeEnvironment();
    return;
    }

    Log.Debug("d3dapp: EnvironmentResized()");
    EnvironmentResized(GUIGraphicsContext.DX9Device, new CancelEventArgs());
    .....


    Neither 'd3dapp: Reset failed ' nor 'd3dapp: EnvironmentResized()' appear in my trace at the problem area (timestamp 22:33:35.265625), but does appear at the one that worked (timestamp 20:28:24.468750).

    Presumably this is because the call to GUIGraphicsContext.DX9Device.Reset is failing, but the subsequent Log.Error isn't writing the ex.Message because the wrong number of parameters is specified.

    So correcting this trace statement my lead me to more info, I guess. Now, to figure out how to compile this :confused:

    I could be wrong though as I'm neither a C# nor a Windows programmer. More an old-style C on unix. Apologies if I'm talking out my rear.
     

    smadger

    Portal Member
    October 12, 2006
    17
    2
    Home Country
    Ireland Ireland
    I added trace and reproduced. Turns out that there is a problem in TexturePacker:dispose() which occasionally throws a 'Collection was modified'. Now I don't know what's causing that problem, but I know that it was causing the code in D3DApp:RecoverDevice() to enter the catch for failing to Reset(). In this catch, there was a call to InitialiseEnvironment().

    So basically, if the reset failed, InitialiseEnvironment() was called. This was messing up later on and throwing lots of exceptions because the correct tidy up hadn't been completed.

    This seems back to front to me. Surely if the disposing and the reset succeeded, it is then that InitialiseEnvironment() should be called.

    So I changed the code to do this and it works.

    I've attached a mediaportal.log showing the dispose failing, but because we now drop out immediately, the dispose succeeds the next time it tries to recover the display.

    I've also attached a svn .patch file for my fix.
     

    Attachments

    • d3dapp.cs.patch
      30.6 KB

    rtv

    Retired Team Member
  • Premium Supporter
  • April 7, 2005
    3,622
    301
    Osnabruck
    Home Country
    Germany Germany
    Thank you for your effords - we're currently investigating about the best way to fix the original issue (Texture cleanup) to avoid adding another workaround which might come with an issue.
     

    smadger

    Portal Member
    October 12, 2006
    17
    2
    Home Country
    Ireland Ireland
    No problem.

    If you have any trouble replicating it and want me to take an update with extra trace/whatever, let me know.

    Thanks for your help, guys
     

    Users who are viewing this thread

    Top Bottom