Skip to content

fix(cv): name the opencv lib when an app opted out of it - #1624

Open
msluszniak wants to merge 1 commit into
mainfrom
@ms/opencv-optout-error
Open

msluszniak wants to merge 1 commit into
mainfrom
@ms/opencv-optout-error

Conversation

@msluszniak

Copy link
Copy Markdown
Member

Description

  • CV ops call the native cv namespace through cvJsi(), which throws INVALID_STATE naming the opencv lib when the app opted out of it, instead of Cannot read property 'resize' of undefined.
  • The image preprocessor checks it on creation, so CV tasks fail at construction.

Introduces a breaking change?

  • Yes
  • No

Type of change

  • Bug fix (change which fixes an issue)
  • New feature (change which adds functionality)
  • Documentation update (improves or adds clarity to existing documentation)
  • Other (chores, tests, code style improvements etc.)

Tested on

  • iOS
  • Android

Testing instructions

  • yarn workspace react-native-executorch test (new case in classification.test.ts).
  • In an app with "libs": [], creating a classifier now rejects with the message above.

Screenshots

Related issues

Closes #1618

Checklist

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly
  • My changes generate no new warnings

Additional notes

With OpenCV off the native installer never adds the cv namespace, so every CV
task failed with "Cannot read property 'resize' of undefined". Route the
calls through cvJsi(), which throws INVALID_STATE naming the lib to add, and
check it when the image preprocessor is created so tasks fail at construction.

Closes #1618
@msluszniak msluszniak self-assigned this Nov 5, 2026
@msluszniak msluszniak added the bug fix PRs that are fixing bugs label Nov 5, 2026
@msluszniak
msluszniak requested a review from barhanc November 5, 2026 17:25

@barhanc barhanc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Other than the naming nit, looks good.

* has no OpenCV.
* @internal
*/
export function cvJsi() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe something like tryInitJsiCv would better convey what this function does.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug fix PRs that are fixing bugs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenCV opt-out: CV tasks throw a raw TypeError

2 participants