Skip to content

fix: correct image source path and enhance error handling for image loading#22

Open
EndoTheDev wants to merge 1 commit intokk8bit:mainfrom
EndoTheDev:main
Open

fix: correct image source path and enhance error handling for image loading#22
EndoTheDev wants to merge 1 commit intokk8bit:mainfrom
EndoTheDev:main

Conversation

@EndoTheDev
Copy link

PR summary

  • Fix resource path casing and harden GuLuLu image handling in web/gululu.js to prevent runtime errors when the image is missing or not yet loaded.

What changed

  • Corrected image source path casing:
    • "/extensions/kaytool/resources/GuLuLu.gif" -> "/extensions/KayTool/resources/GuLuLu.gif"
  • Added image load error handler:
    • Logs a warning and clears pixelDataCache on img.onerror.
  • Added readiness checks before drawing:
    • Skip drawing and clear cache if image is not present, not complete, or has zero natural width.
  • Wrapped drawImage/getImageData in try/catch:
    • Logs a warning and clears pixelDataCache on failure to avoid uncaught exceptions.
  • Minor: ensured newline at end of file.

Motivation

  • Prevents uncaught exceptions from drawImage/getImageData when the image fails to load or is not ready.
  • Fixes a casing bug that can break resource lookup on case-sensitive filesystems/servers.
  • Improves stability and logging so failures are observable without breaking the UI.

Testing / QA steps

  1. Load the app and confirm GuLuLu renders and animates when the GIF is present.
  2. Rename or remove web/resources/GuLuLu.gif to simulate a missing resource; confirm:
    • No uncaught exceptions in console.
    • A console warning "KayTool: GuLuLu image failed to load" appears.
    • No visual crashes; pixelDataCache is cleared.
  3. Resize the window/container and verify no errors occur and behavior remains correct when the image is available.
  4. Verify the extension folder name is KayTool (capitalization) on the deployment environment.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant