UltraStar-Deluxe / USDX

The free and open source karaoke singing game UltraStar Deluxe, inspired by Sony SingStar™
https://usdx.eu
GNU General Public License v2.0
812 stars 160 forks source link

USDX randomly throws errors sometimes (seldom) #542

Open natrius opened 3 years ago

natrius commented 3 years ago

Actual behaviour

Tell us what happens

grafik


---------------------------
UltraStar Deluxe - www.usdx.eu V 2020.4.0 stable Build
---------------------------
Sorry, an error ocurred! Please report this error to the game-developers. Also check the Error.log file in the game folder.

Stacktrace:
Exception class: ERangeError
Message: Range check error

  $00471CCD  TINI__SAVEWEBCAMSETTINGS,  line 2154 of base/UIni.pas
  $0051B49A  TSCREENOPTIONSWEBCAM__PARSEINPUT,  line 106 of screens/UScreenOptionsWebcam.pas
  $0043692C  TDISPLAY__PARSEINPUT,  line 674 of menu/UDisplay.pas
  $0044F4BB  CHECKEVENTS,  line 565 of base/UMain.pas
  $0044E757  MAINLOOP,  line 322 of base/UMain.pas
  $0044E59C  MAIN,  line 266 of base/UMain.pas
  $00402B72  main,  line 411 of ultrastardx.dpr
---------------------------
OK   
---------------------------

Expected behaviour

No error.

Steps to reproduce

Not reproduceable right now, but a smilar error happened before already.

Details

Provide some additional information:

HermannDppes commented 3 years ago

Looking into UIni.pas I find starting at line 211:

      // WebCam                                                                  
      WebCamID:         integer;                                                 
      WebcamResolution: integer;                                                 
      WebCamFPS:        integer;                                                 
      WebCamFlip:       integer;                                                 
      WebCamBrightness: integer;                                                 
      WebCamSaturation: integer;                                                 
      WebCamHue:        integer;                                                 
      WebCamEffect:     integer;

But starting at line 2149:

    // WebCam                                                                    
    IniFile.WriteInteger('Webcam', 'ID', WebCamID);                              
    IniFile.WriteString('Webcam', 'Resolution', IWebcamResolution[WebcamResolution]);
    IniFile.WriteInteger('Webcam', 'FPS', StrToInt(IWebcamFPS[WebCamFPS]));      

    IniFile.WriteString('Webcam', 'Flip', IWebcamFlip[WebcamFlip]);              
    IniFile.WriteString('Webcam', 'Brightness', IWebcamBrightness[WebcamBrightness]);
    IniFile.WriteString('Webcam', 'Saturation', IWebcamSaturation[WebcamSaturation]);
    IniFile.WriteString('Webcam', 'Hue', IWebcamHue[WebcamHue]);                 
    IniFile.WriteInteger('Webcam', 'Effect', WebcamEffect); 

So, the WebcamFlip in line 2154 is the first where the casing does not match. Could this be the source of the error? I do not know enough about Pascal. I mean it should be case-insenstive, right? But it is a strange coincidence.

HermannDppes commented 3 years ago

It is indeed coincidence, the error is clearly the following line:

  WebCamFlip := ReadArrayIndex(IWebcamFlipTranslated, IniFile, 'Webcam', 'Flip', IGNORE_INDEX, 'On');

where it should read IWebcamFlip instead (without the Translated). I'll prepare a PR.

natrius commented 3 years ago

Interesting, because it happened just once. The next time it did not happen again, will check again after another restart. Thanks for looking into it @HermannDppes :)

HermannDppes commented 3 years ago

Do you recall whether you changed around themes (or at least opened the corresponding submenu) in the USDX session that threw this error?

HermannDppes commented 3 years ago

I have a repro on a fresh build from the current master.

This will consistently crash. The crash does not occur otherwise as changing a theme is one of the rare instances (maybe the only one?) where the Ini file is read after the initial read, during which the locale is still identical with the English version.

natrius commented 3 years ago

Yes, pretty sure i changed the theme. Was looking at the themes and so on.