mjrgh / PinballY

A table browser and launcher ("front end") for virtual pinball cabinets.
Other
47 stars 22 forks source link

CustomScripting - mainWindow.on("gamestarted") not fired... #242

Closed Zappo-II closed 2 months ago

Zappo-II commented 2 months ago

I am doing custom javascript and want to react on "gamestarted" as described in the docs...

At first I tried:

mainWindow.on("gamestarted", ev => {
  logfile.log("UN - DEBUG: ENTER LaunchEvent", ev.type);
  logfile.log("UN - DEBUG: EXIT LaunchEvent", ev.type);
});

...but nothing got logged...

Then I tried:

mainWindow.on("prelaunch gamestarted gameover launcherror postlaunch runafter runafterpost runbefore runbeforepre", ev => {
  logfile.log("UN - DEBUG: ENTER LaunchEvent", ev.type);
  logfile.log("UN - DEBUG: EXIT LaunchEvent", ev.type);
});

and got this (stripped down) after starting a table and coming back from it:

[Script] UN - DEBUG: ENTER LaunchEvent prelaunch
[Script] UN - DEBUG: EXIT LaunchEvent prelaunch
[Script] UN - DEBUG: ENTER LaunchEvent runbeforepre
[Script] UN - DEBUG: EXIT LaunchEvent runbeforepre
[Script] UN - DEBUG: ENTER LaunchEvent runbefore
[Script] UN - DEBUG: EXIT LaunchEvent runbefore
[Script] UN - DEBUG: ENTER LaunchEvent gameover
[Script] UN - DEBUG: EXIT LaunchEvent gameover
[Script] UN - DEBUG: ENTER LaunchEvent runafter
[Script] UN - DEBUG: EXIT LaunchEvent runafter
[Script] UN - DEBUG: ENTER LaunchEvent runafterpost
[Script] UN - DEBUG: EXIT LaunchEvent runafterpost
[Script] UN - DEBUG: ENTER LaunchEvent postlaunch
[Script] UN - DEBUG: EXIT LaunchEvent postlaunch

To Reproduce

Expected behavior

Windows version

Additional context

Freitag, 13. September 2024, 15:35:21: Session started
PinballY 1.1.0 (Beta 7), build 9973 (x64, 20240902-0159)

DOF (DirectOutput): initializing DOF client

DOF: creating DOF COM object (a23bfdbc-9a8a-46c0-8672-60f23d54ffb6)
DOF: got table mapping file: C:\PinCab\DirectOutput\tablemappings.xml

Starting pinball player system setup
The main table database folder is C:\PinCab\PinballY\Databases
Pinball player system "Visual Pinball 9" is disabled; skipping
Pinball player system "Visual Pinball 9.2" is disabled; skipping

Configuring pinball player system "Visual Pinball X"
+ database folder = C:\PinCab\PinballY\Databases\Visual Pinball X
+ full executable path to player program is C:\PinCab\Visual.Pinball\VPinballX.exe
+ working path when launching player program is C:\PinCab\Visual.Pinball\
+ full table path (folder containing this system's table files) is C:\PinCab\Visual.Pinball\Tables
+ scanning for table files: C:\PinCab\Visual.Pinball\Tables\*.vpx
++ found file:  FlexDemo.vpx
++ found file:  Indiana Jones (Stern 2008) - JP v4.vpx
++ found file:  JP's Arcade Physics v3.01 Rubber objects.vpx
++ found file:  JP's Space Cadet v4.3.vpx
++ found file:  JP's VPX7 Elasticity_Test.vpx
++ found file:  Nudge Test and Calibration.vpx
++ found file:  Star Trek LE (Stern 2013) - JP v4.vpx
++ found file:  Terminator 2 - JP v3.0.vpx
++ found file:  Terminator 2 - Judgment Day (Williams 1991) NF.vpx
++ found file:  Terminator 2 - Judgment Day (Williams 1991).vpx
++ found file:  Terminator 2 - Judgment Day Chrome Edition-3-2.vpx
++ found file:  Terminator 2 - Judgment Day(Williams 1991)_Bigus(MOD)1.2.vpx

[...]

Checking for Javascript main script file C:\PinCab\PinballY\scripts\main.js
. Main script file exists; initializing Javascript engine
. Loading system script file C:\PinCab\PinballY\scripts\system\CParser.js
. Loading system script file C:\PinCab\PinballY\scripts\system\SystemClasses.js
. Loading main script file C:\PinCab\PinballY\scripts\main.js
[Javascript] Loading module from file C:\PinCab\PinballY\scripts\main.js
[Javascript] Loading module from file C:\PinCab\PinballY\Scripts\UlliMatePinBoldt.js
Zappo-II commented 2 months ago

This is the Log Sequence where I would assume that the missing event should fire...

Media file lookup for Terminator 2 Chrome Edition: Wheel Image, path C:\PinCab\PinballY\Media\Visual Pinball X\Wheel Images, found C:\PinCab\PinballY\Media\Visual Pinball X\Wheel Images\Terminator 2 Chrome Edition (Williams 1991).png
[Script] UN - DEBUG: ENTER LaunchEvent runbefore
[Script] UN - DEBUG: event.command == command.PlayGame
[Script] UN - DEBUG: EXIT LaunchEvent runbefore
+ table launch: executable: C:\PinCab\Visual.Pinball\VPinballX.exe
+ table launch: applying command line variable substitutions:
+ Original> /minimized /play -"[TABLEPATH]\[TABLEFILE]"
+ Final   > /minimized /play -"C:\PinCab\Visual.Pinball\Tables\Terminator 2 - Judgment Day Chrome Edition-3-2.vpx"
[Script] UN - DEBUG: ENTER KeyEvent keyup Digit1
[Script] UN - DEBUG: EXIT KeyEvent keyup Digit1
+ table launch: process launch succeeded

Media file lookup for Terminator 2 Chrome Edition: Wheel Image, path C:\PinCab\PinballY\Media\Visual Pinball X\Wheel Images, found C:\PinCab\PinballY\Media\Visual Pinball X\Wheel Images\Terminator 2 Chrome Edition (Williams 1991).png
[Script] UN - DEBUG: ENTER KeyEvent keybgdown Digit1
[Script] UN - DEBUG: EXIT KeyEvent keybgdown Digit1
[Script] UN - DEBUG: ENTER KeyEvent keybgdown Escape
[Script] UN - DEBUG: EXIT KeyEvent keybgdown Escape

Media file lookup for Terminator 2 Chrome Edition: Wheel Image, path C:\PinCab\PinballY\Media\Visual Pinball X\Wheel Images, found C:\PinCab\PinballY\Media\Visual Pinball X\Wheel Images\Terminator 2 Chrome Edition (Williams 1991).png
+ table launch: Close Game command received
+ table launch: trying to close the game process

Re-scanning for all systems' table files due to application activation
+ scanning for table files: C:\PinCab\Visual.Pinball\Tables\*.vpx
[Script] UN - DEBUG: ENTER KeyEvent keybgup Escape
[Script] UN - DEBUG: EXIT KeyEvent keybgup Escape

Re-scanning for all systems' table files due to application activation
+ scanning for table files: C:\PinCab\Visual.Pinball\Tables\*.vpx
+ table launch: game exited normally
[Script] UN - DEBUG: ENTER LaunchEvent gameover
[Script] UN - DEBUG: event.command == command.PlayGame
[Script] UN - DEBUG: EXIT LaunchEvent gameover
Zappo-II commented 2 months ago

State the obvious:

mjrgh commented 2 months ago

Thanks for the detailed test scenario. I'll take a look.

mjrgh commented 2 months ago

Well, it seems to be working for me, so it must be something specific to your setup. As a sanity check, try disabling all of your scripts (just move all of the .js files out of the scripts folder and stash them somewhere else), and create a script that only tries the gamestarted event, as in

mainWindow.on("gamestarted", ev => {
    logfile.log("Game Started: %s", ev.game.displayName);
});

(which is the simple test case I'm trying). Let's see if it works in the simplest case like that. If so, then my guess would be that some other scripting issue is interfering with either the setup of that event or its delivery, so you'd probably need to start bringing back the other scripts incrementally until it stops working, which should eventually isolate the source of the trouble.

Zappo-II commented 2 months ago

Ok, I'll give it a shot, but since my first attempt was not that different I'd assume that it won't come up with any other insights... I'll let you know anyways as soon as I get home from office and near my cab...

mjrgh commented 2 months ago

Let me know what you find. The main thing is to just make sure that there aren't any other scripts loaded, to be sure that the problem isn't somewhere else. If it still doesn't work in isolation, maybe the next thing to try is REALLY isolating it by setting up a clean install with NOTHING else around, no media files or non-default settings, just a completely fresh install. I can't imagine how media or settings could be affecting it, but it's got to be something about the environment, since it works on my setup.

Zappo-II commented 2 months ago

I took a windows 10 vm and did a clean x64 install of Visual PinBallX 10.7.2 and PinballY x64.msi...(yes, I am aware that Visual Pinball won't make any sense in this environment but for the Sake of CleanInstall and checkup of PinballY functionality I definitely think that this approach is valid)...

In PinballY Options:

I created a main.js with only...

mainWindow.on("gamestarted", ev => {
    logfile.log("Game Started: %s", ev.game.displayName);
});

...inside

Started PinballY and chose the calibration test table...

Nothing got logged...

This is the full story of it all...

Donnerstag, 19. September 2024, 13:51:36: Session started
PinballY 1.1.0 (Beta 7), build 9973 (x64, 20240902-0159)

DOF (DirectOutput): initializing DOF client

DOF: creating DOF COM object (a23bfdbc-9a8a-46c0-8672-60f23d54ffb6)
DOF: DOF COM object (a23bfdbc-9a8a-46c0-8672-60f23d54ffb6) is not registered on this system; DOF will not be used for this session
+ Launching DOF surrogate process.  This is required because PinballY is running
  in 64-bit, and DOF is a 32-bit COM object.  Surrogate command line:
  >"C:\PinballY\Dof3264Surrogate.exe"  -parent_pid=576 -clsid=e2972d0c-5383-4e0f-861f-3d0169738bf0

DOF: creating DOF COM object (a23bfdbc-9a8a-46c0-8672-60f23d54ffb6)
DOF: DOF COM object (a23bfdbc-9a8a-46c0-8672-60f23d54ffb6) is not registered on this system; DOF will not be used for this session

DOF (DirectOutput): initializing DOF client

DOF: creating DOF COM object (a23bfdbc-9a8a-46c0-8672-60f23d54ffb6)
DOF: DOF COM object (a23bfdbc-9a8a-46c0-8672-60f23d54ffb6) is not registered on this system; DOF will not be used for this session

DOF: creating DOF COM object (a23bfdbc-9a8a-46c0-8672-60f23d54ffb6)

Starting pinball player system setup
DOF: DOF COM object (a23bfdbc-9a8a-46c0-8672-60f23d54ffb6) is not registered on this system; DOF will not be used for this session
The main table database folder is C:\PinballY\Databases
Pinball player system "Visual Pinball 9" is disabled; skipping
Pinball player system "Visual Pinball 9.2" is disabled; skipping

Configuring pinball player system "Visual Pinball X"
+ database folder = C:\PinballY\Databases\Visual Pinball X
+ full executable path to player program is C:\Visual Pinball\VPinballX.exe
+ working path when launching player program is C:\Visual Pinball\
+ full table path (folder containing this system's table files) is C:\Visual Pinball\Tables
+ scanning for table files: C:\Visual Pinball\Tables\*.vpx
++ found file:  FlexDemo.vpx
++ found file:  JP's VPX7 Elasticity_Test.vpx
++ found file:  Nudge Test and Calibration.vpx
+ media folder base name is Visual Pinball X, full path is C:\PinballY\Media\Visual Pinball X; this is default folder name, which is the same as the system name
+ searching folder C:\PinballY\Databases\Visual Pinball X for table database .XML files
Pinball player system "Future Pinball" is disabled; skipping
Pinball player system "Pinball Arcade" is disabled; skipping
Pinball player system "Pinball FX3" is disabled; skipping
Pinball player system "Pinball FX2" is disabled; skipping

Window layout setup: initializing Playfield window
  Normal position (when not maximized or full-screen): Left,top = 596, 38; Right,bottom = 1896, 814; Size = 1300 x 776
  Full screen mode = No
  Borderless = No
  Show Mode = 1 (SW_SHOWNORMAL)

Window layout setup: initializing Backglass window
  Normal position (when not maximized or full-screen): Left,top = 8, 24; Right,bottom = 590, 612; Size = 582 x 588
  Full screen mode = No
  Borderless = No
  Show Mode = 1 (SW_SHOWNORMAL)

Window layout setup: initializing DMD window
  Normal position (when not maximized or full-screen): Left,top = 11, 618; Right,bottom = 593, 818; Size = 582 x 200
  Full screen mode = No
  Borderless = No
  Show Mode = 1 (SW_SHOWNORMAL)

Window layout setup: initializing Topper window
  Normal position (when not maximized or full-screen): Left,top = 701, 596; Right,bottom = 1397, 922; Size = 696 x 326
  Full screen mode = No
  Borderless = No
  Show Mode = 0 (SW_HIDE)

Window layout setup: initializing Instruction Card window
  Normal position (when not maximized or full-screen): Left,top = 130, 587; Right,bottom = 667, 906; Size = 537 x 319
  Full screen mode = No
  Borderless = No
  Show Mode = 0 (SW_HIDE)

Checking for Javascript main script file C:\PinballY\scripts\main.js
. Main script file exists; initializing Javascript engine
. Loading system script file C:\PinballY\scripts\system\CParser.js
. Loading system script file C:\PinballY\scripts\system\SystemClasses.js
. Loading main script file C:\PinballY\scripts\main.js
[Javascript] Loading module from file C:\PinballY\scripts\main.js
High score retrieval (init): VPinMAME NVRAM path is C:\Visual Pinball\VPinMame\nvram
High score retrieval (init): PinEMHi .ini file path is C:\PinballY\PINemHi\PINemHi.ini
PinEMHi command line: "C:\PinballY\PINemHi\PINemHi.exe"  -v
High score retrieval (init): PinEMHi ini data loaded successfully
High score retrieval (init): path for VP is D:\per\VisualPinball\VPinMame\nvram\
High score retrieval (init): path for FP is D:\Games\Future Pinball\fpRAM\
Searching for Startup Video in C:\PinballY\Media\Startup Videos.*
Searching for Startup Video in C:\PinballY\Assets\Startup Videos.*
Searching for Startup Video (bg) in C:\PinballY\Media\Startup Videos.*
Searching for Startup Video (bg) in C:\PinballY\Assets\Startup Videos.*
Searching for Startup Video (dmd) in C:\PinballY\Media\Startup Videos.*
Searching for Startup Video (dmd) in C:\PinballY\Assets\Startup Videos.*
Searching for Startup Video (instcard) in C:\PinballY\Media\Startup Videos.*
Searching for Startup Video (instcard) in C:\PinballY\Assets\Startup Videos.*
Searching for Startup Video (topper) in C:\PinballY\Media\Startup Videos.*
Searching for Startup Video (topper) in C:\PinballY\Assets\Startup Videos.*
Searching for underlay in C:\PinballY\Media\Images.*
Searching for underlay in C:\PinballY\Assets\Images.*
Searching for Default Playfield in C:\PinballY\Media\Videos.*
Searching for Default Playfield in C:\PinballY\Assets\Videos.*
Searching for Default Playfield in C:\PinballY\Media\Images.*
Searching for Default Playfield in C:\PinballY\Assets\Images.*
Searching for Default Playfield in C:\PinballY\Media\Videos.*
Searching for Default Playfield in C:\PinballY\Assets\Videos.*
Searching for Default Playfield in C:\PinballY\Media\Images.*
Searching for Default Playfield in C:\PinballY\Assets\Images.*
Searching for Startup Audio in C:\PinballY\Media\Startup Sounds.*
Searching for Startup Audio in C:\PinballY\Assets\Startup Sounds.*
High score retrieval: getting high scores for Nudge Test and Calibration
High score retrieval: can't use PINemHi because this game isn't configured for a particular game player system
High score retrieval: looking for ad hoc scores file C:\Visual Pinball\Tables\Nudge Test and Calibration.pinballyHighScores
+ ad hoc scores file C:\Visual Pinball\Tables\Nudge Test and Calibration.pinballyHighScores doesn't exist
+ No high score source found for Nudge Test and Calibration
Searching for Default Backglass in C:\PinballY\Media\Videos.*
Searching for Default Backglass in C:\PinballY\Assets\Videos.*
Searching for Default Backglass in C:\PinballY\Media\Images.*
Searching for Default Backglass in C:\PinballY\Assets\Images.*
Searching for Default DMD in C:\PinballY\Media\Videos.*
Searching for Default DMD in C:\PinballY\Assets\Videos.*
Searching for Default DMD in C:\PinballY\Media\Images.*
Searching for Default DMD in C:\PinballY\Assets\Images.*
Searching for Deselect in C:\PinballY\Media\Button Sounds.*
Searching for Deselect in C:\PinballY\Assets\Button Sounds.*
PinEMHi completed successfully; results:
>>>

                   Version 1.3.1

Supports all Future Pinball-Games Top 10 Hiscores
        Supports 425 Visual Pinball-Games
              Supports 1240 Roms
   *** Compatible with Visual pinmame 3.0 ***

            Written by Dna Disturber

>>>
Searching for Next in C:\PinballY\Media\Button Sounds.*
Searching for Next in C:\PinballY\Assets\Button Sounds.*
Searching for underlay in C:\PinballY\Media\Images.*
Searching for underlay in C:\PinballY\Assets\Images.*
Searching for Default Playfield in C:\PinballY\Media\Videos.*
Searching for Default Playfield in C:\PinballY\Assets\Videos.*
Searching for Default Playfield in C:\PinballY\Media\Images.*
Searching for Default Playfield in C:\PinballY\Assets\Images.*
Searching for Default Playfield in C:\PinballY\Media\Videos.*
Searching for Default Playfield in C:\PinballY\Assets\Videos.*
Searching for Default Playfield in C:\PinballY\Media\Images.*
Searching for Default Playfield in C:\PinballY\Assets\Images.*
High score retrieval: getting high scores for FlexDemo
High score retrieval: can't use PINemHi because this game isn't configured for a particular game player system
High score retrieval: looking for ad hoc scores file C:\Visual Pinball\Tables\FlexDemo.pinballyHighScores
+ ad hoc scores file C:\Visual Pinball\Tables\FlexDemo.pinballyHighScores doesn't exist
+ No high score source found for FlexDemo
Searching for Default Backglass in C:\PinballY\Media\Videos.*
Searching for Default Backglass in C:\PinballY\Assets\Videos.*
Searching for Default Backglass in C:\PinballY\Media\Images.*
Searching for Default Backglass in C:\PinballY\Assets\Images.*
Searching for Next in C:\PinballY\Media\Button Sounds.*
Searching for Next in C:\PinballY\Assets\Button Sounds.*
Searching for Default DMD in C:\PinballY\Media\Videos.*
Searching for Default DMD in C:\PinballY\Assets\Videos.*
Searching for Default DMD in C:\PinballY\Media\Images.*
Searching for Default DMD in C:\PinballY\Assets\Images.*
Searching for underlay in C:\PinballY\Media\Images.*
Searching for underlay in C:\PinballY\Assets\Images.*
Searching for Default Playfield in C:\PinballY\Media\Videos.*
Searching for Default Playfield in C:\PinballY\Assets\Videos.*
Searching for Default Playfield in C:\PinballY\Media\Images.*
Searching for Default Playfield in C:\PinballY\Assets\Images.*
Searching for Default Playfield in C:\PinballY\Media\Videos.*
Searching for Default Playfield in C:\PinballY\Assets\Videos.*
Searching for Default Playfield in C:\PinballY\Media\Images.*
Searching for Default Playfield in C:\PinballY\Assets\Images.*
High score retrieval: getting high scores for JP's VPX7 Elasticity_Test
High score retrieval: can't use PINemHi because this game isn't configured for a particular game player system
High score retrieval: looking for ad hoc scores file C:\Visual Pinball\Tables\JP's VPX7 Elasticity_Test.pinballyHighScores
+ ad hoc scores file C:\Visual Pinball\Tables\JP's VPX7 Elasticity_Test.pinballyHighScores doesn't exist
+ No high score source found for JP's VPX7 Elasticity_Test
Searching for Default Backglass in C:\PinballY\Media\Videos.*
Searching for Default Backglass in C:\PinballY\Assets\Videos.*
Searching for Default Backglass in C:\PinballY\Media\Images.*
Searching for Default Backglass in C:\PinballY\Assets\Images.*
Searching for Next in C:\PinballY\Media\Button Sounds.*
Searching for Next in C:\PinballY\Assets\Button Sounds.*
Searching for Default DMD in C:\PinballY\Media\Videos.*
Searching for Default DMD in C:\PinballY\Assets\Videos.*
Searching for Default DMD in C:\PinballY\Media\Images.*
Searching for Default DMD in C:\PinballY\Assets\Images.*
Searching for underlay in C:\PinballY\Media\Images.*
Searching for underlay in C:\PinballY\Assets\Images.*
Searching for Default Playfield in C:\PinballY\Media\Videos.*
Searching for Default Playfield in C:\PinballY\Assets\Videos.*
Searching for Default Playfield in C:\PinballY\Media\Images.*
Searching for Default Playfield in C:\PinballY\Assets\Images.*
Searching for Default Playfield in C:\PinballY\Media\Videos.*
Searching for Default Playfield in C:\PinballY\Assets\Videos.*
Searching for Default Playfield in C:\PinballY\Media\Images.*
Searching for Default Playfield in C:\PinballY\Assets\Images.*
Searching for Default Backglass in C:\PinballY\Media\Videos.*
Searching for Default Backglass in C:\PinballY\Assets\Videos.*
Searching for Default Backglass in C:\PinballY\Media\Images.*
Searching for Default Backglass in C:\PinballY\Assets\Images.*
Searching for Select in C:\PinballY\Media\Button Sounds.*
Searching for Select in C:\PinballY\Assets\Button Sounds.*
Searching for Select in C:\PinballY\Media\Button Sounds.*
Searching for Select in C:\PinballY\Assets\Button Sounds.*

Table launch: Nudge Test and Calibration, table file Nudge Test and Calibration.vpx, system Visual Pinball X

DOF: shutting down DOF client
Searching for Game Launch Background in C:\PinballY\Media\Videos.*
+ launch: full table path C:\Visual Pinball\Tables\Nudge Test and Calibration.vpx
Searching for Game Launch Background in C:\PinballY\Assets\Videos.*
Searching for Game Launch Background in C:\PinballY\Media\Images.*
Searching for Game Launch Background in C:\PinballY\Assets\Images.*
Searching for Launch in C:\PinballY\Media\Button Sounds.*
Searching for Launch in C:\PinballY\Assets\Button Sounds.*
+ table launch: executable: C:\Visual Pinball\VPinballX.exe
+ table launch: applying command line variable substitutions:
+ Original> /minimized /play -"[TABLEPATH]\[TABLEFILE]"
+ Final   > /minimized /play -"C:\Visual Pinball\Tables\Nudge Test and Calibration.vpx"
+ table launch: process launch succeeded

Re-scanning for all systems' table files due to application activation
+ scanning for table files: C:\Visual Pinball\Tables\*.vpx
Searching for Select in C:\PinballY\Media\Button Sounds.*
Searching for Select in C:\PinballY\Assets\Button Sounds.*
+ table launch: child process exited normally
+ table launch finished successfully
Searching for underlay in C:\PinballY\Media\Images.*
Searching for underlay in C:\PinballY\Assets\Images.*
Searching for Default Playfield in C:\PinballY\Media\Videos.*
Searching for Default Playfield in C:\PinballY\Assets\Videos.*
Searching for Default Playfield in C:\PinballY\Media\Images.*
Searching for Default Playfield in C:\PinballY\Assets\Images.*
Searching for Default Playfield in C:\PinballY\Media\Videos.*
Searching for Default Playfield in C:\PinballY\Assets\Videos.*
Searching for Default Playfield in C:\PinballY\Media\Images.*
Searching for Default Playfield in C:\PinballY\Assets\Images.*
High score retrieval: getting high scores for Nudge Test and Calibration
High score retrieval: can't use PINemHi because this game isn't configured for a particular game player system
High score retrieval: looking for ad hoc scores file C:\Visual Pinball\Tables\Nudge Test and Calibration.pinballyHighScores
+ ad hoc scores file C:\Visual Pinball\Tables\Nudge Test and Calibration.pinballyHighScores doesn't exist
+ No high score source found for Nudge Test and Calibration

Re-scanning for all systems' table files due to application activation
+ scanning for table files: C:\Visual Pinball\Tables\*.vpx
Searching for Default Backglass in C:\PinballY\Media\Videos.*
Searching for Default Backglass in C:\PinballY\Assets\Videos.*
Searching for Default Backglass in C:\PinballY\Media\Images.*
Searching for Default Backglass in C:\PinballY\Assets\Images.*

DOF (DirectOutput): initializing DOF client

DOF: creating DOF COM object (a23bfdbc-9a8a-46c0-8672-60f23d54ffb6)
DOF: DOF COM object (a23bfdbc-9a8a-46c0-8672-60f23d54ffb6) is not registered on this system; DOF will not be used for this session

DOF: creating DOF COM object (a23bfdbc-9a8a-46c0-8672-60f23d54ffb6)
DOF: DOF COM object (a23bfdbc-9a8a-46c0-8672-60f23d54ffb6) is not registered on this system; DOF will not be used for this session
Searching for Default DMD in C:\PinballY\Media\Videos.*
Searching for Default DMD in C:\PinballY\Assets\Videos.*
Searching for Default DMD in C:\PinballY\Media\Images.*
Searching for Default DMD in C:\PinballY\Assets\Images.*

Re-scanning for all systems' table files due to application activation
+ scanning for table files: C:\Visual Pinball\Tables\*.vpx

Re-scanning for all systems' table files due to application activation
+ scanning for table files: C:\Visual Pinball\Tables\*.vpx

Re-scanning for all systems' table files due to application activation
+ scanning for table files: C:\Visual Pinball\Tables\*.vpx
Searching for Select in C:\PinballY\Media\Button Sounds.*
Searching for Select in C:\PinballY\Assets\Button Sounds.*
Searching for Next in C:\PinballY\Media\Button Sounds.*
Searching for Next in C:\PinballY\Assets\Button Sounds.*
Searching for Select in C:\PinballY\Media\Button Sounds.*
Searching for Select in C:\PinballY\Assets\Button Sounds.*

DOF: shutting down DOF client

Donnerstag, 19. September 2024, 13:56:22: PinballY session ending

Just to make sure, I did this afterwards:

In main.js ...

mainWindow.on("prelaunch gamestarted gameover launcherror postlaunch runafter runafterpost runbefore runbeforepre", ev => {
    logfile.log("%s: %s", ev.type, ev.game.displayName);
});

...and all the other events got logged, but not gamestarted...

Donnerstag, 19. September 2024, 14:06:58: Session started
PinballY 1.1.0 (Beta 7), build 9973 (x64, 20240902-0159)

DOF (DirectOutput): initializing DOF client

DOF: creating DOF COM object (a23bfdbc-9a8a-46c0-8672-60f23d54ffb6)
DOF: DOF COM object (a23bfdbc-9a8a-46c0-8672-60f23d54ffb6) is not registered on this system; DOF will not be used for this session
+ Launching DOF surrogate process.  This is required because PinballY is running
  in 64-bit, and DOF is a 32-bit COM object.  Surrogate command line:
  >"C:\PinballY\Dof3264Surrogate.exe"  -parent_pid=3332 -clsid=c0557e4e-e263-45da-8ab2-c520e13b7146

DOF: creating DOF COM object (a23bfdbc-9a8a-46c0-8672-60f23d54ffb6)
DOF: DOF COM object (a23bfdbc-9a8a-46c0-8672-60f23d54ffb6) is not registered on this system; DOF will not be used for this session

DOF (DirectOutput): initializing DOF client

DOF: creating DOF COM object (a23bfdbc-9a8a-46c0-8672-60f23d54ffb6)
DOF: DOF COM object (a23bfdbc-9a8a-46c0-8672-60f23d54ffb6) is not registered on this system; DOF will not be used for this session

DOF: creating DOF COM object (a23bfdbc-9a8a-46c0-8672-60f23d54ffb6)

Starting pinball player system setup
DOF: DOF COM object (a23bfdbc-9a8a-46c0-8672-60f23d54ffb6) is not registered on this system; DOF will not be used for this session
The main table database folder is C:\PinballY\Databases
Pinball player system "Visual Pinball 9" is disabled; skipping
Pinball player system "Visual Pinball 9.2" is disabled; skipping

Configuring pinball player system "Visual Pinball X"
+ database folder = C:\PinballY\Databases\Visual Pinball X
+ full executable path to player program is C:\Visual Pinball\VPinballX.exe
+ working path when launching player program is C:\Visual Pinball\
+ full table path (folder containing this system's table files) is C:\Visual Pinball\Tables
+ scanning for table files: C:\Visual Pinball\Tables\*.vpx
++ found file:  FlexDemo.vpx
++ found file:  JP's VPX7 Elasticity_Test.vpx
++ found file:  Nudge Test and Calibration.vpx
+ media folder base name is Visual Pinball X, full path is C:\PinballY\Media\Visual Pinball X; this is default folder name, which is the same as the system name
+ searching folder C:\PinballY\Databases\Visual Pinball X for table database .XML files
Pinball player system "Future Pinball" is disabled; skipping
Pinball player system "Pinball Arcade" is disabled; skipping
Pinball player system "Pinball FX3" is disabled; skipping
Pinball player system "Pinball FX2" is disabled; skipping

Window layout setup: initializing Playfield window
  Normal position (when not maximized or full-screen): Left,top = 596, 38; Right,bottom = 1896, 814; Size = 1300 x 776
  Full screen mode = No
  Borderless = No
  Show Mode = 1 (SW_SHOWNORMAL)

Window layout setup: initializing Backglass window
  Normal position (when not maximized or full-screen): Left,top = 8, 24; Right,bottom = 590, 612; Size = 582 x 588
  Full screen mode = No
  Borderless = No
  Show Mode = 1 (SW_SHOWNORMAL)

Window layout setup: initializing DMD window
  Normal position (when not maximized or full-screen): Left,top = 11, 618; Right,bottom = 593, 818; Size = 582 x 200
  Full screen mode = No
  Borderless = No
  Show Mode = 1 (SW_SHOWNORMAL)

Window layout setup: initializing Topper window
  Normal position (when not maximized or full-screen): Left,top = 701, 596; Right,bottom = 1397, 922; Size = 696 x 326
  Full screen mode = No
  Borderless = No
  Show Mode = 0 (SW_HIDE)

Window layout setup: initializing Instruction Card window
  Normal position (when not maximized or full-screen): Left,top = 130, 587; Right,bottom = 667, 906; Size = 537 x 319
  Full screen mode = No
  Borderless = No
  Show Mode = 0 (SW_HIDE)

Checking for Javascript main script file C:\PinballY\scripts\main.js
. Main script file exists; initializing Javascript engine
. Loading system script file C:\PinballY\scripts\system\CParser.js
. Loading system script file C:\PinballY\scripts\system\SystemClasses.js
. Loading main script file C:\PinballY\scripts\main.js
[Javascript] Loading module from file C:\PinballY\scripts\main.js
High score retrieval (init): VPinMAME NVRAM path is C:\Visual Pinball\VPinMame\nvram
High score retrieval (init): PinEMHi .ini file path is C:\PinballY\PINemHi\PINemHi.ini
PinEMHi command line: "C:\PinballY\PINemHi\PINemHi.exe"  -v
High score retrieval (init): PinEMHi ini data loaded successfully
High score retrieval (init): path for VP is D:\per\VisualPinball\VPinMame\nvram\
High score retrieval (init): path for FP is D:\Games\Future Pinball\fpRAM\
Searching for Startup Video in C:\PinballY\Media\Startup Videos.*
Searching for Startup Video in C:\PinballY\Assets\Startup Videos.*
Searching for Startup Video (bg) in C:\PinballY\Media\Startup Videos.*
Searching for Startup Video (bg) in C:\PinballY\Assets\Startup Videos.*
Searching for Startup Video (dmd) in C:\PinballY\Media\Startup Videos.*
Searching for Startup Video (dmd) in C:\PinballY\Assets\Startup Videos.*
Searching for Startup Video (instcard) in C:\PinballY\Media\Startup Videos.*
Searching for Startup Video (instcard) in C:\PinballY\Assets\Startup Videos.*
Searching for Startup Video (topper) in C:\PinballY\Media\Startup Videos.*
Searching for Startup Video (topper) in C:\PinballY\Assets\Startup Videos.*
Searching for underlay in C:\PinballY\Media\Images.*
Searching for underlay in C:\PinballY\Assets\Images.*
Searching for Default Playfield in C:\PinballY\Media\Videos.*
Searching for Default Playfield in C:\PinballY\Assets\Videos.*
Searching for Default Playfield in C:\PinballY\Media\Images.*
Searching for Default Playfield in C:\PinballY\Assets\Images.*
Searching for Default Playfield in C:\PinballY\Media\Videos.*
Searching for Default Playfield in C:\PinballY\Assets\Videos.*
Searching for Default Playfield in C:\PinballY\Media\Images.*
Searching for Default Playfield in C:\PinballY\Assets\Images.*
Searching for Startup Audio in C:\PinballY\Media\Startup Sounds.*
Searching for Startup Audio in C:\PinballY\Assets\Startup Sounds.*
High score retrieval: getting high scores for Nudge Test and Calibration
High score retrieval: can't use PINemHi because this game isn't configured for a particular game player system
High score retrieval: looking for ad hoc scores file C:\Visual Pinball\Tables\Nudge Test and Calibration.pinballyHighScores
+ ad hoc scores file C:\Visual Pinball\Tables\Nudge Test and Calibration.pinballyHighScores doesn't exist
+ No high score source found for Nudge Test and Calibration
Searching for Default Backglass in C:\PinballY\Media\Videos.*
Searching for Default Backglass in C:\PinballY\Assets\Videos.*
Searching for Default Backglass in C:\PinballY\Media\Images.*
Searching for Default Backglass in C:\PinballY\Assets\Images.*
Searching for Default DMD in C:\PinballY\Media\Videos.*
Searching for Default DMD in C:\PinballY\Assets\Videos.*
Searching for Default DMD in C:\PinballY\Media\Images.*
Searching for Default DMD in C:\PinballY\Assets\Images.*
PinEMHi completed successfully; results:
>>>

                   Version 1.3.1

Supports all Future Pinball-Games Top 10 Hiscores
        Supports 425 Visual Pinball-Games
              Supports 1240 Roms
   *** Compatible with Visual pinmame 3.0 ***

            Written by Dna Disturber

>>>
Searching for Deselect in C:\PinballY\Media\Button Sounds.*
Searching for Deselect in C:\PinballY\Assets\Button Sounds.*
Searching for Next in C:\PinballY\Media\Button Sounds.*
Searching for Next in C:\PinballY\Assets\Button Sounds.*
Searching for underlay in C:\PinballY\Media\Images.*
Searching for underlay in C:\PinballY\Assets\Images.*
Searching for Default Playfield in C:\PinballY\Media\Videos.*
Searching for Default Playfield in C:\PinballY\Assets\Videos.*
Searching for Default Playfield in C:\PinballY\Media\Images.*
Searching for Default Playfield in C:\PinballY\Assets\Images.*
Searching for Default Playfield in C:\PinballY\Media\Videos.*
Searching for Default Playfield in C:\PinballY\Assets\Videos.*
Searching for Default Playfield in C:\PinballY\Media\Images.*
Searching for Default Playfield in C:\PinballY\Assets\Images.*
High score retrieval: getting high scores for FlexDemo
High score retrieval: can't use PINemHi because this game isn't configured for a particular game player system
High score retrieval: looking for ad hoc scores file C:\Visual Pinball\Tables\FlexDemo.pinballyHighScores
+ ad hoc scores file C:\Visual Pinball\Tables\FlexDemo.pinballyHighScores doesn't exist
+ No high score source found for FlexDemo
Searching for Next in C:\PinballY\Media\Button Sounds.*
Searching for Next in C:\PinballY\Assets\Button Sounds.*
Searching for Default Backglass in C:\PinballY\Media\Videos.*
Searching for Default Backglass in C:\PinballY\Assets\Videos.*
Searching for Default Backglass in C:\PinballY\Media\Images.*
Searching for Default Backglass in C:\PinballY\Assets\Images.*
Searching for Next in C:\PinballY\Media\Button Sounds.*
Searching for Next in C:\PinballY\Assets\Button Sounds.*
Searching for Next in C:\PinballY\Media\Button Sounds.*
Searching for Next in C:\PinballY\Assets\Button Sounds.*
Searching for Next in C:\PinballY\Media\Button Sounds.*
Searching for Next in C:\PinballY\Assets\Button Sounds.*
Searching for Default DMD in C:\PinballY\Media\Videos.*
Searching for Default DMD in C:\PinballY\Assets\Videos.*
Searching for Default DMD in C:\PinballY\Media\Images.*
Searching for Default DMD in C:\PinballY\Assets\Images.*
Searching for Next in C:\PinballY\Media\Button Sounds.*
Searching for Next in C:\PinballY\Assets\Button Sounds.*
Searching for Next in C:\PinballY\Media\Button Sounds.*
Searching for Next in C:\PinballY\Assets\Button Sounds.*
Searching for Next in C:\PinballY\Media\Button Sounds.*
Searching for Next in C:\PinballY\Assets\Button Sounds.*
Searching for underlay in C:\PinballY\Media\Images.*
Searching for underlay in C:\PinballY\Assets\Images.*
Searching for Default Playfield in C:\PinballY\Media\Videos.*
Searching for Default Playfield in C:\PinballY\Assets\Videos.*
Searching for Default Playfield in C:\PinballY\Media\Images.*
Searching for Default Playfield in C:\PinballY\Assets\Images.*
Searching for Default Playfield in C:\PinballY\Media\Videos.*
Searching for Default Playfield in C:\PinballY\Assets\Videos.*
Searching for Default Playfield in C:\PinballY\Media\Images.*
Searching for Default Playfield in C:\PinballY\Assets\Images.*
High score retrieval: getting high scores for JP's VPX7 Elasticity_Test
High score retrieval: can't use PINemHi because this game isn't configured for a particular game player system
High score retrieval: looking for ad hoc scores file C:\Visual Pinball\Tables\JP's VPX7 Elasticity_Test.pinballyHighScores
+ ad hoc scores file C:\Visual Pinball\Tables\JP's VPX7 Elasticity_Test.pinballyHighScores doesn't exist
+ No high score source found for JP's VPX7 Elasticity_Test
Searching for Next in C:\PinballY\Media\Button Sounds.*
Searching for Next in C:\PinballY\Assets\Button Sounds.*
Searching for underlay in C:\PinballY\Media\Images.*
Searching for underlay in C:\PinballY\Assets\Images.*
Searching for Default Playfield in C:\PinballY\Media\Videos.*
Searching for Default Playfield in C:\PinballY\Assets\Videos.*
Searching for Default Playfield in C:\PinballY\Media\Images.*
Searching for Default Playfield in C:\PinballY\Assets\Images.*
Searching for Default Playfield in C:\PinballY\Media\Videos.*
Searching for Default Playfield in C:\PinballY\Assets\Videos.*
Searching for Default Playfield in C:\PinballY\Media\Images.*
Searching for Default Playfield in C:\PinballY\Assets\Images.*
Searching for Default Backglass in C:\PinballY\Media\Videos.*
Searching for Default Backglass in C:\PinballY\Assets\Videos.*
Searching for Default Backglass in C:\PinballY\Media\Images.*
Searching for Default Backglass in C:\PinballY\Assets\Images.*
Searching for Default DMD in C:\PinballY\Media\Videos.*
Searching for Default DMD in C:\PinballY\Assets\Videos.*
Searching for Default DMD in C:\PinballY\Media\Images.*
Searching for Default DMD in C:\PinballY\Assets\Images.*
Searching for Select in C:\PinballY\Media\Button Sounds.*
Searching for Select in C:\PinballY\Assets\Button Sounds.*
Searching for Select in C:\PinballY\Media\Button Sounds.*
Searching for Select in C:\PinballY\Assets\Button Sounds.*

Table launch: Nudge Test and Calibration, table file Nudge Test and Calibration.vpx, system Visual Pinball X
[Script] prelaunch: Nudge Test and Calibration

DOF: shutting down DOF client
Searching for Game Launch Background in C:\PinballY\Media\Videos.*
Searching for Game Launch Background in C:\PinballY\Assets\Videos.*
Searching for Game Launch Background in C:\PinballY\Media\Images.*
Searching for Game Launch Background in C:\PinballY\Assets\Images.*
Searching for Launch in C:\PinballY\Media\Button Sounds.*
Searching for Launch in C:\PinballY\Assets\Button Sounds.*
+ launch: full table path C:\Visual Pinball\Tables\Nudge Test and Calibration.vpx
[Script] runbeforepre: Nudge Test and Calibration
[Script] runbefore: Nudge Test and Calibration
+ table launch: executable: C:\Visual Pinball\VPinballX.exe
+ table launch: applying command line variable substitutions:
+ Original> /minimized /play -"[TABLEPATH]\[TABLEFILE]"
+ Final   > /minimized /play -"C:\Visual Pinball\Tables\Nudge Test and Calibration.vpx"
+ table launch: process launch succeeded
+ table launch: child process exited normally

Re-scanning for all systems' table files due to application activation
+ scanning for table files: C:\Visual Pinball\Tables\*.vpx
[Script] gameover: Nudge Test and Calibration
[Script] runafter: Nudge Test and Calibration
[Script] runafterpost: Nudge Test and Calibration
+ table launch finished successfully
[Script] postlaunch: Nudge Test and Calibration
Searching for underlay in C:\PinballY\Media\Images.*
Searching for underlay in C:\PinballY\Assets\Images.*
Searching for Default Playfield in C:\PinballY\Media\Videos.*
Searching for Default Playfield in C:\PinballY\Assets\Videos.*
Searching for Default Playfield in C:\PinballY\Media\Images.*
Searching for Default Playfield in C:\PinballY\Assets\Images.*
Searching for Default Playfield in C:\PinballY\Media\Videos.*
Searching for Default Playfield in C:\PinballY\Assets\Videos.*
Searching for Default Playfield in C:\PinballY\Media\Images.*
Searching for Default Playfield in C:\PinballY\Assets\Images.*
High score retrieval: getting high scores for Nudge Test and Calibration
High score retrieval: can't use PINemHi because this game isn't configured for a particular game player system
High score retrieval: looking for ad hoc scores file C:\Visual Pinball\Tables\Nudge Test and Calibration.pinballyHighScores
+ ad hoc scores file C:\Visual Pinball\Tables\Nudge Test and Calibration.pinballyHighScores doesn't exist
+ No high score source found for Nudge Test and Calibration
Searching for Default Backglass in C:\PinballY\Media\Videos.*
Searching for Default Backglass in C:\PinballY\Assets\Videos.*
Searching for Default Backglass in C:\PinballY\Media\Images.*
Searching for Default Backglass in C:\PinballY\Assets\Images.*

DOF (DirectOutput): initializing DOF client

DOF: creating DOF COM object (a23bfdbc-9a8a-46c0-8672-60f23d54ffb6)
DOF: DOF COM object (a23bfdbc-9a8a-46c0-8672-60f23d54ffb6) is not registered on this system; DOF will not be used for this session

DOF: creating DOF COM object (a23bfdbc-9a8a-46c0-8672-60f23d54ffb6)
DOF: DOF COM object (a23bfdbc-9a8a-46c0-8672-60f23d54ffb6) is not registered on this system; DOF will not be used for this session
Searching for Default DMD in C:\PinballY\Media\Videos.*
Searching for Default DMD in C:\PinballY\Assets\Videos.*
Searching for Default DMD in C:\PinballY\Media\Images.*
Searching for Default DMD in C:\PinballY\Assets\Images.*

Re-scanning for all systems' table files due to application activation
+ scanning for table files: C:\Visual Pinball\Tables\*.vpx
Searching for Select in C:\PinballY\Media\Button Sounds.*
Searching for Select in C:\PinballY\Assets\Button Sounds.*
Searching for Next in C:\PinballY\Media\Button Sounds.*
Searching for Next in C:\PinballY\Assets\Button Sounds.*
Searching for Select in C:\PinballY\Media\Button Sounds.*
Searching for Select in C:\PinballY\Assets\Button Sounds.*

DOF: shutting down DOF client

Donnerstag, 19. September 2024, 14:10:36: PinballY session ending

...so, "It works on my machine" seems not to be the default behaviour after Clean Install of PinballY... ???

What Do You Think...???

mjrgh commented 2 months ago

I was about to start adding some instrumentation to try to get to the bottom of this, and in the course of that I came across an error that might be the source of the problem. I say "might" because the error is what's known as a race condition, and those tend to manifest sporadically, whereas you seem to be seeing the problem consistently. But this particular race condition is tied to Windows internals, so it's possible that the sporadicness is more a function of which machine it's running on than random variation from one run to the next, which would align with my inability to reproduce it at all and your ability to reproduce it consistently.

To test this theory, I have an instrumented version for you to try. You should see a new message in the log like this: DEBUG: Fired gamestarted event with table ID.... If that's not there, the problem is something else entirely. If it's there, and the "internal game object" reported in the error is 0 (or a string of zeroes), that would confirm that this is indeed the root cause.

I also included a version with the error fixed (instrumentation still in place).

If the instrumented-unfixed version shows the null (all zeroes) game object, AND the fixed version starts working for you, I think the combination will confirm that this really is the problem.

There's also a chance that the fixed version will work, and the instrumented-but-unfixed version will also work (i.e., that the bug will no longer reproduce on your system with this build, even though the race condition error is still there). The nature of the race condition is that it's dependent on delicate matters of timing, so any perturbation of the code might randomly change the behavior. But I took some care to insert the instrumentation in a minimally disruptive way to try to preserve the timing that I suspect is causing the bug, so hopefully the test will go as outlined above and we can be fairly sure that this is the fix.

PinballY-x64-1.1.0-b7-gamestarted-tests.zip

(Note: the ZIP above just contains the two .exe builds. You should be able to just drop the new .exe's into your current install folder, keeping all of the other files the same.)

Zappo-II commented 2 months ago

Race Condition, huh...??? ...tricky little suckers they are at times... Do you remember the good old days when code was executed strictly serialized...??? :smirk: ...

PinballY-1.1.0-b7-instrumented-unfixed.exe says:

DOF: shutting down DOF client
Searching for Game Launch Background in C:\PinballY\Media\Videos.*
+ launch: full table path C:\Visual Pinball\Tables\Nudge Test and Calibration.vpx
Searching for Game Launch Background in C:\PinballY\Assets\Videos.*
Searching for Game Launch Background in C:\PinballY\Media\Images.*
Searching for Game Launch Background in C:\PinballY\Assets\Images.*
Searching for Launch in C:\PinballY\Media\Button Sounds.*
Searching for Launch in C:\PinballY\Assets\Button Sounds.*
[Script] runbeforepre: Nudge Test and Calibration
[Script] runbefore: Nudge Test and Calibration
+ table launch: executable: C:\Visual Pinball\VPinballX.exe
+ table launch: applying command line variable substitutions:
+ Original> /minimized /play -"[TABLEPATH]\[TABLEFILE]"
+ Final   > /minimized /play -"C:\Visual Pinball\Tables\Nudge Test and Calibration.vpx"

Re-scanning for all systems' table files due to application activation
+ scanning for table files: C:\Visual Pinball\Tables\*.vpx
+ table launch: process launch succeeded
+ table launch: child process exited normally
[Script] gameover: Nudge Test and Calibration
Searching for Default Backglass in C:\PinballY\Media\Videos.*
Searching for Default Backglass in C:\PinballY\Assets\Videos.*
Searching for Default Backglass in C:\PinballY\Media\Images.*
Searching for Default Backglass in C:\PinballY\Assets\Images.*
DEBUG: Fired gamestarted event with table ID 32, sys config index 3, launch command 2256, internal game object 0000000000000000
[Script] runafter: Nudge Test and Calibration
[Script] runafterpost: Nudge Test and Calibration
+ table launch finished successfully
Searching for underlay in C:\PinballY\Media\Images.*
Searching for underlay in C:\PinballY\Assets\Images.*
Searching for Default Playfield in C:\PinballY\Media\Videos.*
Searching for Default Playfield in C:\PinballY\Assets\Videos.*
Searching for Default Playfield in C:\PinballY\Media\Images.*
Searching for Default Playfield in C:\PinballY\Assets\Images.*
Searching for Default Playfield in C:\PinballY\Media\Videos.*
Searching for Default Playfield in C:\PinballY\Assets\Videos.*
Searching for Default Playfield in C:\PinballY\Media\Images.*
Searching for Default Playfield in C:\PinballY\Assets\Images.*
High score retrieval: getting high scores for Nudge Test and Calibration
High score retrieval: can't use PINemHi because this game isn't configured for a particular game player system
High score retrieval: looking for ad hoc scores file C:\Visual Pinball\Tables\Nudge Test and Calibration.pinballyHighScores
+ ad hoc scores file C:\Visual Pinball\Tables\Nudge Test and Calibration.pinballyHighScores doesn't exist
+ No high score source found for Nudge Test and Calibration
[Script] postlaunch: Nudge Test and Calibration
Searching for Default DMD in C:\PinballY\Media\Videos.*
Searching for Default DMD in C:\PinballY\Assets\Videos.*
Searching for Default DMD in C:\PinballY\Media\Images.*
Searching for Default DMD in C:\PinballY\Assets\Images.*

DOF (DirectOutput): initializing DOF client

PinballY-1.1.0-b7-instrumented-unfixed.exe says:

DOF: shutting down DOF client
Searching for Game Launch Background in C:\PinballY\Media\Videos.*
+ launch: full table path C:\Visual Pinball\Tables\Nudge Test and Calibration.vpx
Searching for Game Launch Background in C:\PinballY\Assets\Videos.*
Searching for Game Launch Background in C:\PinballY\Media\Images.*
Searching for Game Launch Background in C:\PinballY\Assets\Images.*
Searching for Launch in C:\PinballY\Media\Button Sounds.*
Searching for Launch in C:\PinballY\Assets\Button Sounds.*
[Script] runbeforepre: Nudge Test and Calibration
[Script] runbefore: Nudge Test and Calibration
+ table launch: executable: C:\Visual Pinball\VPinballX.exe
+ table launch: applying command line variable substitutions:
+ Original> /minimized /play -"[TABLEPATH]\[TABLEFILE]"
+ Final   > /minimized /play -"C:\Visual Pinball\Tables\Nudge Test and Calibration.vpx"

Re-scanning for all systems' table files due to application activation
+ scanning for table files: C:\Visual Pinball\Tables\*.vpx
+ table launch: process launch succeeded
+ table launch: child process exited normally
[Script] gameover: Nudge Test and Calibration
Searching for Default Backglass in C:\PinballY\Media\Videos.*
Searching for Default Backglass in C:\PinballY\Assets\Videos.*
Searching for Default Backglass in C:\PinballY\Media\Images.*
Searching for Default Backglass in C:\PinballY\Assets\Images.*
[Script] gamestarted: Nudge Test and Calibration
DEBUG: Fired gamestarted event with table ID 4, sys config index 3, launch command 32795, internal game object 0000014E633FB610
[Script] runafter: Nudge Test and Calibration
[Script] runafterpost: Nudge Test and Calibration
+ table launch finished successfully
Searching for underlay in C:\PinballY\Media\Images.*
Searching for underlay in C:\PinballY\Assets\Images.*
Searching for Default Playfield in C:\PinballY\Media\Videos.*
Searching for Default Playfield in C:\PinballY\Assets\Videos.*
Searching for Default Playfield in C:\PinballY\Media\Images.*
Searching for Default Playfield in C:\PinballY\Assets\Images.*
Searching for Default Playfield in C:\PinballY\Media\Videos.*
Searching for Default Playfield in C:\PinballY\Assets\Videos.*
Searching for Default Playfield in C:\PinballY\Media\Images.*
Searching for Default Playfield in C:\PinballY\Assets\Images.*
High score retrieval: getting high scores for Nudge Test and Calibration
High score retrieval: can't use PINemHi because this game isn't configured for a particular game player system
High score retrieval: looking for ad hoc scores file C:\Visual Pinball\Tables\Nudge Test and Calibration.pinballyHighScores
+ ad hoc scores file C:\Visual Pinball\Tables\Nudge Test and Calibration.pinballyHighScores doesn't exist
+ No high score source found for Nudge Test and Calibration
[Script] postlaunch: Nudge Test and Calibration
Searching for Default DMD in C:\PinballY\Media\Videos.*
Searching for Default DMD in C:\PinballY\Assets\Videos.*
Searching for Default DMD in C:\PinballY\Media\Images.*
Searching for Default DMD in C:\PinballY\Assets\Images.*

DOF (DirectOutput): initializing DOF client

Without being that much inside your code as you are it looks like at the point of time when you wanted to fire your event the game was not initialized or instantiated yet or not part of the "promise" / event object instantiation...???

In this particular synthetic environment VPX is in fact already shut down again when the game started event hits the log...(in other words, it is logged after the gameover event - concurrency is a bitch)...

So, long story short, your Fix seems to have nailed it...(at least for me)... :hammer: ...

Will you provide a fixed release... :thinking: ...???

Thanx for your eagerness to resolve this issue :heart_eyes: ...

mjrgh commented 2 months ago

Wonderful - those logs definitely look like they confirm the theory. I'll put together a new beta release with the fix shortly.

In this particular synthetic environment VPX is in fact already shut down again when the game started event hits the log...

Interesting observation. It's not really a concurrency issue in the sense you're probably thinking; it's just that "gamestarted" was deliberately being delivered asynchronously, because the internal launch processing code, which predates the Javascript events, doesn't have any need for deterministic ordering of that event for its own purposes. So it was a minor optimization to throw the event in the message queue and process it later as time permitted. But it seems at least counterintuitive for the Javascript launch events to fire out of order like that, and I can easily imagine cases where unpredictable ordering would make scripting more difficult, so I should probably just make it synchronous. I don't think the underlying launch code cares one way or the other, which I think is why it was asynchronous in the first place, so I don't think it will do any harm to change it.

Without being that much inside your code as you are it looks like at the point of time when you wanted to fire your event the game was not initialized or instantiated yet or not part of the "promise" / event object instantiation...???

It was just a case where the lifetime of a data structure wasn't coupled properly to the lifetime of the asynchronous event that references the structure. Depending on how the timing worked out, the data structure either survived long enough or didn't - and if it did survive long enough, it was only an accident that it did, so the code was still conceptually wrong even when it happened to work. It's one of those things that's easy enough to fix once you know it's there, but in this case it managed to stay hidden because for whatever reason the timing seems to always take the accidentally-works branch on my setup.

Zappo-II commented 2 months ago

I can confirm that PinballY 1.1.0 (Beta 8), build 10039 (x64, 20240921-1919) fixes this problem (on my machines) ... 😇 ...

Thanx a lot...

mjrgh commented 2 months ago

Glad to hear it's working!