Unknown uC-FS error 1414 when trying to load bitmap tables

Sometime the function playdate->graphics->loadBitmapTable fails to load image tables with the error uC-FS error: 1414.

file sprite-character_name not found: unknown uC-FS error: 1414

It usually happens when doing the following steps:

  1. locking the playdate
  2. waiting for a little while (more than 5 minutes)
  3. unlocking the playdate and resuming the game
  4. doing something that will load an image, image table or a font

I don't have this problem with other games so I may be doing something bad. Here is how I load bitmap tables:

LCDBitmapTable * _Nonnull LCDBitmapTableLoadOrError(const char * _Nonnull path) {
    const char *error = NULL;
    LCDBitmapTable *bitmapTable = playdate->graphics->loadBitmapTable(path, &error);
    if (error) {
        playdate->system->error("Unable to load bitmap table at path %s, error: %s", path, error);
    }
    return bitmapTable;
}

static void init(Scene * _Nonnull scene) {
    CharacterSelectScene *self = (CharacterSelectScene *)scene;
    // [...]

    LCDBitmapTable *artworks = self->artworks = LCDBitmapTableLoadOrError("sprite-character_select_character");
    CharacterSelectCharacterConstructor(PlayerCharacterKatsuo, &self->selection, artworks);
    CharacterSelectCharacterConstructor(PlayerCharacterSaki, &self->selection, artworks);

    CharacterSelectGridConstructorWithSelection(&self->selection);

    LCDBitmapTable *name = self->names = LCDBitmapTableLoadOrError("sprite-character_name");
    CharacterSelectNameConstructor(PlayerCharacterKatsuo, &self->selection, playdate->graphics->getTableBitmap(name, PlayerCharacterKatsuo));
    CharacterSelectNameConstructor(PlayerCharacterSaki, &self->selection, playdate->graphics->getTableBitmap(name, PlayerCharacterSaki));

    // [...]
}

OK I think I found what was going on here and in fact, I don't think it is related to resuming the game.

My sprite exporter created an image table AND an image with the same name for some of my sprites:
image

I assume that this error code means that the file is not a bitmap or not a bitmap table and I suspect that removing one of the two will fix the error.

EDIT: I removed the files but the error is still happening.
image

Have you confirmed the files have been removed from the device?

1 Like

Yes I removed the PDX before trying again and the Roobert font was not duplicated in the first place :sob:

1 Like

Apparently this error means that the data disk isn't mounted. I have absolutely no idea what could cause this error to show up.

1 Like

Maybe the data disk is mounted whilst the menu is open and unmounted when the game is resumed? which would make sense.

Given that it's happening after the menu is closed, it implies that somehow a reference to a font used in the menu is still hanging around?

I added a retry in the load function and it didn't crashed today. I don't think that this fully fixes the problem but maybe it lower its chances of happening?

LCDBitmapTable * _Nonnull LCDBitmapTableLoadOrError(const char * _Nonnull path) {
    const char *error = NULL;
    LCDBitmapTable *bitmapTable = playdate->graphics->loadBitmapTable(path, &error);
    if (error) {
        playdate->system->logToConsole("Unable to load bitmap table at path %s, error: %s", path, error);

        error = NULL;
        bitmapTable = playdate->graphics->loadBitmapTable(path, &error);
        if (error) {
            playdate->system->error("Unable to load bitmap table at path %s, error: %s", path, error);
        }
    }
    return bitmapTable;
}

Or maybe I am using too much RAM?
EDIT: I found some memory leaks. It may be the root cause.