osu-framework icon indicating copy to clipboard operation
osu-framework copied to clipboard

Null reference in tablet handling

Open ppy-sentryintegration[bot] opened this issue 2 years ago • 1 comments

Sentry Issue: OSU-364

This is not an unhandled exception, but should be handled better.

System.NullReferenceException: Object reference not set to an instance of an object.
  ?, in bool OpenTabletDriverHandler.Initialize(GameHost host)+(object _, IEnumerable<TabletReference> e) => { } [6]
  ?, in bool Driver.Detect()
  ?, in async Task TabletDriver.detectAsync(CancellationToken cancellationToken)

Seeing that this is happening inside the TabletsChanged event callback in OpenTabletDriverHandler, my only guess is that tabletDriver was initialised and disposed of before the event was fired, and once it fired it NRE'd on trying to access tabletDriver.

I'm not entirely sure what causes this, but the event should probably be unsubscribed from before disposing the tablet driver, to ensure no callback is executed after the tablet was disabled, or causing memory leaks (Driver.Dispose doesn't seem to do anything about it).

frenzibyte avatar Sep 18 '22 23:09 frenzibyte

Some additional information:

When attempting to run osu!lazer on aarch64 NixOS through NIXPKGS_ALLOW_UNFREE=1 NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1 nix shell --impure nixpkgs#osu-lazer-bin (which builds version 2023.511.0) followed by running the osu! binary, the following error is thrown and the game crashes:

Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
   at osu.Framework.Input.Handlers.Tablet.OpenTabletDriverHandler.Initialize(GameHost host)
   at osu.Framework.Platform.GameHost.initialiseInputHandlers()
   at osu.Framework.Platform.GameHost.Run(Game game)
   at osu.Desktop.Program.Main(String[] args) in /build/source/osu.Desktop/Program.cs:line 120

It would of course be best to fix the underlying issue for aarch64 Linux systems (works on the same machine on aarch64 Darwin/macOS), but it could temporarily be worked around by disabling only the built-in tablet drivers if they fail to initialize instead of preventing osu! from launching.

gBasil avatar May 30 '23 05:05 gBasil

This is still happening to people, and was tracked across two issues so I've close the others and bumped this to priority 0.

peppy avatar May 30 '23 05:05 peppy