Skip to content

Failed Preloads Without Error Callbacks Cause Permanent Sketch Hang #8420

@Ady0333

Description

@Ady0333

Most appropriate sub-area of p5.js?

  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • p5.strands
  • WebGL
  • DevOps, Build process, Unit testing
  • Internationalization (i18n)
  • Friendly Errors
  • Other (specify if possible)

p5.js version

v1.11.12-rc.0

Web browser and version

Google Chrome 120.0.6099.216 (64-bit)

Operating system

Windows 11 (with WSL2, Ubuntu 22.04)

Steps to reproduce this

Steps:

  1. Create a new p5.js sketch using the default global mode.
  2. Add a preload() function that attempts to load a non-existent asset using a preload helper (e.g. loadImage) without providing an error callback.
  3. Open the sketch in a browser and observe that it remains stuck on “Loading…” indefinitely and setup() / draw() never execute.

Snippet:

let img;

function preload() {
  // Intentionally invalid path to trigger a load failure
  img = loadImage('nonexistent-image.jpg');
}

function setup() {
  // This never runs
  createCanvas(400, 400);
  console.log('setup ran');
}

function draw() {
  // This never runs
  background(220);
  image(img, 0, 0);
}

Observed Behavior:

  • Sketch displays “Loading…” forever

  • No visible error in the sketch output

  • setup() and draw() are never called

  • Error is only visible in the browser console

Expected Behavior:

  • Preload failures should not permanently block sketch execution

  • setup() should run once all preload attempts (success or failure) complete

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions