Skip to content

bug: a missing icon or sound asset crashes the simulator on startup (unguarded loads) #115

Description

@dmccoystephenson

Summary

Two asset loads at startup have no error handling, so a missing or unreadable file takes down the whole application before the simulation can run:

  • src/apex.py:18
    pygame.display.set_icon(pygame.image.load('src/media/icon/icon.PNG'))
    pygame.image.load raises pygame.error / FileNotFoundError if src/media/icon/icon.PNG is absent; nothing guards it, so it propagates out of startup.
  • src/service/soundService.py:9-10
    self.reproduceSoundEffect = pygame.mixer.Sound("src/media/sounds/pop.wav")
    self.deathSoundEffect = pygame.mixer.Sound("src/media/sounds/pain.wav")
    pygame.mixer.Sound(...) raises if the file is missing or the mixer is unavailable. SoundService is constructed during Simulation.__init__, so a missing pop.wav/pain.wav — or simply running on a machine with no audio device where the mixer failed to init — crashes the sim at construction.

These paths use hardcoded asset filenames, so this is a latent hardening gap rather than a routinely-reproducing failure — but it surfaces the moment an asset is renamed, removed from a packaged build, or the host has no working audio, and the failure mode (hard crash at startup) is the worst case.

Why it matters

The app already supports a headless/text use case (text mode is documented for "headless servers" and "remote SSH sessions"), where there is frequently no audio device — exactly the environment in which an unguarded pygame.mixer.Sound is most likely to throw and make the program unusable.

Suggested fix

Wrap the icon load and the SoundService asset loads in try/except (pygame.error, FileNotFoundError), log the offending path once, and degrade gracefully — skip the icon, and make sound playback a no-op when an effect failed to load (or the mixer is unavailable) rather than aborting startup.

Filed by Claude during an automated triage pass; both load sites were read on the default branch and confirmed unguarded (soundService.py is identical across branches; apex.py:18 verified on main).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions