numberonesuperguy

I have a debug script that allows me to abstract my debug logging.

Its worked all week on the Toshiba (it originated from example code for it) and on iHDSim (which I use for getting some clue as to where my 00C errors are!).

But suddenly, today the iHDSim is giving me an HDDVD_E_ARGUMENT script error.

function initialise()

{

// Initialise debugger

var pTrace = Diagnostics.trace;

var listenerCollection = Diagnostics.listeners;

var Index = listenerCollection.add("debugger");

var Item = listenerCollection.item(Index);

pTrace.autoFlush = true;

pTrace.indentLevel = 1;

pTrace.indentSize = 4;

initialiseDebugger( pTrace, listenerCollection, Index, Item );

}

....

var _appDebug;

/**

* Call this just once from the one-off Initialiser.

**/

function initialiseDebugger( diagTrace, diagListeners, Index, dout )

{

_appDebug = new Object();

_appDebug.diagTrace = diagTrace;

_appDebug.diagListeners = diagListeners;

_appDebug.Index = Index;

_appDebug.dout = dout;

}

..........

/**

* Basic debug string output

**/

function debugOut( msg, part, lvl )

{

_appDebug.dout.writeLine( msg, part, lvl );

_appDebug.dout.flush();

}

If I comment out the above 2 highlighted lines, iHDSim is okay again.

Of course the first question is why is iHDSim failing (the Tosh is fine)

This debug file has not changed for days, whereas other scripts have been added and modified which I would have liked to have blamed.

The second question is, how might I write code that can determine what player its running on, and perhaps avoid calling incompatible debug methods...



Re: HD DVD Interactivity Authoring Toshiba debug code on iHDSim

Andy Pennell MSFT

Are you passing -debug on the command-line to ihdsim I am rusty on the details, but players only support the diagnostics API when in "diagnostic mode", else they throw exceptions. Use a try/catch to see if a given player supports the diagnostics or not.




Re: HD DVD Interactivity Authoring Toshiba debug code on iHDSim

Andy Pennell MSFT

I checked and ihdsim is always in diagnostics mode. I don't see a way for the code to throw an error: can you run it under the script debugger and tell us exactly which line is throwing the error




Re: HD DVD Interactivity Authoring Toshiba debug code on iHDSim

numberonesuperguy

The same as me: I stumped as to how unchanged code started throwing an error!! It was reporting an error on line 83 in 'unknown file' so after playing with all the line 83's in my project, debug.js was the last file I tried and... here I am!

I have Visual Studio installed, and I think because its the Express edition I can't get the debugger working (I'm launching with HDiSim -debug -jit -p "<path>").

So trying to download the 90 day trial of the full VS 2005, it gets as far as downloading 2.5k of a 2.6GB 'iso' file. And stops. I tried it in Opera before IE, and it reported a 'stopped' status instead of a 'finished' status so I'm guessing a web server problem somewhere (or could it be my proxy ).

I'll try again later, but unless there is a way to use another script debugger or Express, I'm stuck...!

However, you mentioned HDiSim does support the same debug interface as the Toshiba: Could you tell me where to find the debug output

thx,

Nathan.





Re: HD DVD Interactivity Authoring Toshiba debug code on iHDSim

Andy Pennell MSFT

If you use a File listener, ihdsim will write the diagnostics out to the file "diagnostics.txt" - try that.




Re: HD DVD Interactivity Authoring Toshiba debug code on iHDSim

Amy Dullard - MSFT

I think that the script is fine. I think the problem is with the arguments being passed. If you are passing invalid arguments into writeLine, this will throw a HDDVD_E_ARGUMENT exception.

You should verify that msg and part are non-null strings and that lvl is an unsigned int (1 for error, 2 for warning, 3 for info)






Re: HD DVD Interactivity Authoring Toshiba debug code on iHDSim

Amy Dullard - MSFT

I believe the diagnostic text file is stored in C:\Program Files\HD DVD Interactivity Jumpstart\HDDVDSimulator

You can also print debug text to the screen if you want immediate feedback.

Unchanged code can start throwing an error because of different implementations of the player firmware. Sometimes its because one player has EXTRA support that isn't defined in the spec and so another player won't support it. Sometimes its because of a bug in player firmware. Keep in mind that there will be many more players on the market in the next year with a variety of different implemenations. Obviously, you do NOT want an unhandled exception to be thrown in the real world which result in a player crash. So, to prepare, please make sure to handle all exceptions!!! Peter Torr wrote a great blog about this a few weeks ago...

http://blogs.msdn.com/ptorr/archive/2007/06/01/using-conditional-compilation-in-hdi.aspx

EVERY HDI DEVELOPER SHOULD READ THIS BLOG POST!!! You don't want to just write apps that work on the players currently available - write apps that will work on future ones too!






Re: HD DVD Interactivity Authoring Toshiba debug code on iHDSim

numberonesuperguy

Thanks for your help so far, it looks like the 'writeLine' method I'm using doesn't like the DOM Elements returned by HDiSim.

Using code like...

var mmElement = document.getElementById( "menu_main" );

myDiagnosticsListenersItem.writeLine( mmElement, "main_menu", 0 );

...was my problem. Even though the typeof mmElement is 'object', there doesnt seem to be a toString() method on it, and I'm guessing thats the real problem here.

But I still haven't found the diagnostics.txt anywhere on my harddrive...!

I was given the following code to get hold of a debug text file handle...

var listenerCollection = Diagnostics.listeners;

var Index = listenerCollection.add("debugger");

var myDiagnosticsListenersItem = listenerCollection.item(Index);

Would this affect what and where the file is I've searched my entire hard drive for 'diagnostics.txt' and 'debugger' and can't find it!

thnx





Re: HD DVD Interactivity Authoring Toshiba debug code on iHDSim

Peter Torr - MSFT

toString is a method defined by ECMAScript, and doesn't exist on most host obects. Try taking a look at my latest blog post for some other ideas -- http://blogs.msdn.com/ptorr/archive/2007/06/27/helpful-tracing-routines.aspx




Re: HD DVD Interactivity Authoring Toshiba debug code on iHDSim

numberonesuperguy

Thanks Peter, but I'm not sure what you mean by 'host objects' or why it would exist on some and not all. As far as I'm concerned the purposed of .toString() has always been as an aid to logging and debugging, and as such is why it is part of Object.prototype and therefore part of all other objects (so not to need to write extra debug code).

On the Toshiba it worked fine, it was only the HDiSim that it wasnt working with

However, I'm completely failing to find the diagnostic.txt file. Any help there would really ...help!

thnx,

Nathan.





Re: HD DVD Interactivity Authoring Toshiba debug code on iHDSim

Rankin Kern - MSFT

Hi Nathan,

diagnostics.txt should appear in the same directory as the HDiSim executable you are running.

Thanks,

--Rankin




Re: HD DVD Interactivity Authoring Toshiba debug code on iHDSim

Milo Winningham

On the Toshiba emulators, you use a "debugger" type listener to log to a file, but in HDiSim you need to use a "file" type debugger.

Use

var
Index = listenerCollection.add("file");

instead of

var
Index = listenerCollection.add("debugger");




Re: HD DVD Interactivity Authoring Toshiba debug code on iHDSim

Peter Torr - MSFT

A "host" object (or "native" object) is anything provided by the environment in which ECMAScript is running. It doesn't have to follow the rules of ECMAScript at all. All the objects defined by HD DVD are host / native objects.

The "built in" objects like String, Array, etc. are all defined by the ECMA 262 spec.






Re: HD DVD Interactivity Authoring Toshiba debug code on iHDSim

numberonesuperguy

Thanks Peter. I guessed this is the situation, but I was trying to point out the Toshiba implementation had the foresight to give these host objects (that claim to be type of javascript 'object' on both HDiSim and Toshiba player) at least the .toString() method.

You advise these objects don't have to follow the JS Object spec, but lets face it, theres no reason why they shouldn't!

So would you be for or against a move advising other implementors to implement the base 'object' methods, and perhaps 'fix' the MS implementation

Thanks,

Nathan.





Re: HD DVD Interactivity Authoring Toshiba debug code on iHDSim

Peter Torr - MSFT

I would be against it, mostly because it is a lot of work to specify the behaviour for every possible object in every possible situation, and for very little value. You can easily write your own ObjectToString function that knows how to handle the objects you care about, without waiting for the DVD Forum to decide what the value should be (which may not be what you want, anyway) and waiting for all the players to update.