{"record":{"id":"74e1aef1695f080e","repo":"bumptech/glide","slug":"recursive-registry-initialization-in-your-appglid","errorCode":null,"errorMessage":"Recursive Registry initialization! In your AppGlideModule and LibraryGlideModules, Make sure you're using the provided Registry rather calling glide.getRegistry()!","messagePattern":"Recursive Registry initialization! In your AppGlideModule and LibraryGlideModules, Make sure you're using the provided Registry rather calling glide\\.getRegistry\\(\\)!","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"library/src/main/java/com/bumptech/glide/RegistryFactory.java","lineNumber":102,"sourceCode":"import java.util.List;\n\nfinal class RegistryFactory {\n\n  private RegistryFactory() {}\n\n  static GlideSupplier<Registry> lazilyCreateAndInitializeRegistry(\n      final Glide glide,\n      final List<GlideModule> manifestModules,\n      @Nullable final AppGlideModule annotationGeneratedModule) {\n    return new GlideSupplier<Registry>() {\n      // Rely on callers using memoization if they want to avoid duplicate work, but\n      // rely on ourselves to verify that no recursive initialization occurs.\n      private boolean isInitializing;\n\n      @Override\n      public Registry get() {\n        if (isInitializing) {\n          throw new IllegalStateException(\n              \"Recursive Registry initialization! In your\"\n                  + \" AppGlideModule and LibraryGlideModules, Make sure you're using the provided \"\n                  + \"Registry rather calling glide.getRegistry()!\");\n        }\n        Trace.beginSection(\"Glide registry\");\n        isInitializing = true;\n        try {\n          return createAndInitRegistry(glide, manifestModules, annotationGeneratedModule);\n        } finally {\n          isInitializing = false;\n          Trace.endSection();\n        }\n      }\n    };\n  }\n\n  @Synthetic\n  static Registry createAndInitRegistry(","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/bumptech/glide/blob/eb14a895d8f866e6a08c3e19d50ea3bd2c12c20a/library/src/main/java/com/bumptech/glide/RegistryFactory.java#L84-L120","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["In every registerComponents override, use the Registry parameter passed to the method, not glide.getRegistry()","Search your codebase for 'getRegistry()' calls inside any class extending AppGlideModule or LibraryGlideModule and replace them with the local registry argument","If you need the Glide instance for something other than registry access, pass it through but never call getRegistry() on it during initialization"],"exampleFix":"// before\n@Override\npublic void registerComponents(Context context, Glide glide, Registry registry) {\n  glide.getRegistry().append(MyModel.class, new MyModelLoader.Factory());\n}\n// after\n@Override\npublic void registerComponents(Context context, Glide glide, Registry registry) {\n  registry.append(MyModel.class, new MyModelLoader.Factory());\n}","handlingStrategy":"validation","validationCode":"// Before writing registerComponents, audit all references:\n// In any AppGlideModule / LibraryGlideModule, never call glide.getRegistry().\n// Use only the 'registry' parameter passed to registerComponents.\n@Override\npublic void registerComponents(Context context, Glide glide, Registry registry) {\n  // CORRECT: use the provided registry\n  registry.append(MyModel.class, new MyModelLoader.Factory());\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never call glide.getRegistry() inside registerComponents; always use the registry parameter","Add a lint rule or code review checklist item that flags getRegistry() calls in GlideModule subclasses","Keep registerComponents implementations minimal — only append/replace on the provided registry"],"tags":["glide","registry","initialization","recursion"],"backgroundTag":null,"analyzedSha":"eb14a895d8f866e6a08c3e19d50ea3bd2c12c20a","analyzedAt":"2026-08-14T01:43:54.821Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}