Skip to content

fix: expose unload() JSI binding for TextToImageModule#947

Merged
chmjkb merged 1 commit intosoftware-mansion:mainfrom
yocontra:fix/text-to-image-unload
Mar 9, 2026
Merged

fix: expose unload() JSI binding for TextToImageModule#947
chmjkb merged 1 commit intosoftware-mansion:mainfrom
yocontra:fix/text-to-image-unload

Conversation

@yocontra
Copy link
Contributor

@yocontra yocontra commented Mar 8, 2026

Summary

TextToImage::unload() is implemented in C++ and correctly delegates to its sub-components (encoder, unet, decoder), but the JSI binding was never registered in ModelHostObject. This causes a TypeError: this.nativeModule.unload is not a function when calling BaseModule.delete() from JavaScript.

Every other composite model (OCR, VerticalOCR, Kokoro, LLM) already registers unload in its if constexpr block — this adds the same one-liner for TextToImage.

Changes

  • Added unload JSI export to the TextToImage block in ModelHostObject.h, matching the existing pattern used by other models

Test plan

  • Call module.delete() on a loaded TextToImageModule — should no longer throw
  • Verify model memory is released after delete() (encoder, unet, decoder sub-models are unloaded)

TextToImage.unload() exists in C++ but was never registered as a JSI
host function, causing `TypeError: this.nativeModule.unload is not a
function` when calling BaseModule.delete() from JS.

Every other composite model (OCR, VerticalOCR, Kokoro, LLM) already
registers unload in its `if constexpr` block — this adds the same
one-liner for TextToImage.
Copy link
Collaborator

@chmjkb chmjkb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@chmjkb chmjkb merged commit f43d3c5 into software-mansion:main Mar 9, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants