bumptech/glide · error · IllegalStateException

Recursive Registry initialization! In your AppGlideModule an

Error message

Recursive Registry initialization! In your AppGlideModule and LibraryGlideModules, Make sure you're using the provided Registry rather calling glide.getRegistry()!

What it means

Glide detects re-entrant Registry initialization via an isInitializing guard in the lazilyCreateAndInitializeRegistry GlideSupplier. During app startup, Glide builds the Registry by invoking each GlideModule's registerComponents method. If any module calls glide.getRegistry() inside registerComponents, that call re-enters the same supplier's get() method while isInitializing is still true, tripping the guard. The fix is always to use the Registry instance passed as a parameter rather than asking the Glide singleton for it.

Source

Thrown at library/src/main/java/com/bumptech/glide/RegistryFactory.java:102

import java.util.List;

final class RegistryFactory {

  private RegistryFactory() {}

  static GlideSupplier<Registry> lazilyCreateAndInitializeRegistry(
      final Glide glide,
      final List<GlideModule> manifestModules,
      @Nullable final AppGlideModule annotationGeneratedModule) {
    return new GlideSupplier<Registry>() {
      // Rely on callers using memoization if they want to avoid duplicate work, but
      // rely on ourselves to verify that no recursive initialization occurs.
      private boolean isInitializing;

      @Override
      public Registry get() {
        if (isInitializing) {
          throw new IllegalStateException(
              "Recursive Registry initialization! In your"
                  + " AppGlideModule and LibraryGlideModules, Make sure you're using the provided "
                  + "Registry rather calling glide.getRegistry()!");
        }
        Trace.beginSection("Glide registry");
        isInitializing = true;
        try {
          return createAndInitRegistry(glide, manifestModules, annotationGeneratedModule);
        } finally {
          isInitializing = false;
          Trace.endSection();
        }
      }
    };
  }

  @Synthetic
  static Registry createAndInitRegistry(

View on GitHub (pinned to eb14a895d8)

Solutions

  1. In every registerComponents override, use the Registry parameter passed to the method, not glide.getRegistry()
  2. Search your codebase for 'getRegistry()' calls inside any class extending AppGlideModule or LibraryGlideModule and replace them with the local registry argument
  3. If you need the Glide instance for something other than registry access, pass it through but never call getRegistry() on it during initialization

Example fix

// before
@Override
public void registerComponents(Context context, Glide glide, Registry registry) {
  glide.getRegistry().append(MyModel.class, new MyModelLoader.Factory());
}
// after
@Override
public void registerComponents(Context context, Glide glide, Registry registry) {
  registry.append(MyModel.class, new MyModelLoader.Factory());
}
Defensive patterns

Strategy: validation

Validate before calling

// Before writing registerComponents, audit all references:
// In any AppGlideModule / LibraryGlideModule, never call glide.getRegistry().
// Use only the 'registry' parameter passed to registerComponents.
@Override
public void registerComponents(Context context, Glide glide, Registry registry) {
  // CORRECT: use the provided registry
  registry.append(MyModel.class, new MyModelLoader.Factory());
}

Prevention

When it happens

Trigger: An AppGlideModule or LibraryGlideModule override of registerComponents(Context, Glide, Registry) calls glide.getRegistry().append(...) or glide.getRegistry().replace(...) instead of using the provided registry argument. The supplier's get() is invoked recursively because getRegistry() delegates to the same lazy supplier currently mid-initialization.

Common situations: Custom AppGlideModule implementations that register a custom ModelLoader or ResourceDecoder. Code copied from an outdated Glide v3 tutorial that used Glide.get().registry patterns. Large apps with multiple LibraryGlideModules where one module was written against an older API.

Related errors


AI-assisted analysis of bumptech/glide@eb14a895d8 (2026-08-14). Data as JSON: /api/errors/74e1aef1695f080e. Report an issue: GitHub.