mozilla/pdf.js · warning · Error
No ML.
Error message
No ML.
What it means
Thrown by StampEditor.mlGuessAltText when this._uiManager.mlManager is null/undefined. The ML manager is an optional, host-provided integration (e.g., Firefox's built-in model); when it is not registered, alt-text guessing is unavailable and the method aborts rather than silently returning garbage.
Source
Thrown at src/display/editor/stamp.js:165
});
try {
// The alt-text dialog isn't opened but we still want to guess the alt
// text.
this.mlGuessAltText();
} catch {}
}
this.div.focus();
}
async mlGuessAltText(imageData = null, updateAltTextData = true) {
if (this.hasAltTextData()) {
return null;
}
const { mlManager } = this._uiManager;
if (!mlManager) {
throw new Error("No ML.");
}
if (!(await mlManager.isEnabledFor("altText"))) {
throw new Error("ML isn't enabled for alt text.");
}
const { data, width, height } =
imageData ||
this.copyCanvas(null, null, /* createImageData = */ true).imageData;
const response = await mlManager.guess({
name: "altText",
request: {
data,
width,
height,
channels: data.length / (width * height),
},
});
if (!response) {
throw new Error("No response from the AI service.");View on GitHub (pinned to 5903d58d58)
Solutions
- Check for mlManager availability before calling: if (!editor._uiManager.mlManager) return null.
- Register an mlManager implementation on the UI manager if you want the feature.
- Feature-detect and hide the 'Guess alt text' UI when no mlManager is present.
Example fix
// before
const alt = await stampEditor.mlGuessAltText(imageData);
// after
if (!stampEditor._uiManager.mlManager) {
// alt-text ML is not available in this build/host
return null;
}
const alt = await stampEditor.mlGuessAltText(imageData); Defensive patterns
Strategy: type-guard
Validate before calling
function canGuessAltText(editor) {
return !!editor._uiManager?.mlManager;
}
if (canGuessAltText(stampEditor)) {
return stampEditor.mlGuessAltText(imageData);
} Type guard
const hasMlManager = (e): boolean => !!e?._uiManager?.mlManager;
Try / catch
null
Prevention
- Hide alt-text-guess UI when no mlManager is registered.
- Treat ML as an optional capability in your feature detection.
- Provide a manual alt-text path as the default.
When it happens
Trigger: Calling mlGuessAltText in a generic/embedding context where no mlManager was passed to the editor UI manager; calling it before the host wired up the ML integration.
Common situations: Using pdfjs-dist outside Firefox and trying to use alt-text guessing; calling the API in tests without stubbing mlManager; feature gated off by the host application.
Related errors
- ML isn't enabled for alt text.
- XFA: Cannot save new annotations.
- extractPages: partial pageIndices cannot be combined with in
- extractPages: invalid page index.
- extractPages: overlapping pageIndices.
AI-assisted analysis of mozilla/pdf.js@5903d58d58 (2026-08-13).
Data as JSON: /api/errors/8f503899282d1b10.
Report an issue: GitHub.