Skip to content

fix(ios): change BOOL* to BOOL in stop/pause RCT_EXPORT_METHOD to fix RN bridge marshalling crash#296

Open
rupen5989 wants to merge 1 commit into
ak1394:masterfrom
rupen5989:fix/ios-bool-pointer-marshalling
Open

fix(ios): change BOOL* to BOOL in stop/pause RCT_EXPORT_METHOD to fix RN bridge marshalling crash#296
rupen5989 wants to merge 1 commit into
ak1394:masterfrom
rupen5989:fix/ios-bool-pointer-marshalling

Conversation

@rupen5989

Copy link
Copy Markdown

Problem

On React Native 0.85+, calling Tts.stop() or Tts.pause() on iOS throws a red-screen render error:

TextToSpeech.stop(): Error while converting JavaScript argument 0 to Objective C type BOOL. Objective C type BOOL is unsupported.

Root cause: TextToSpeech.m declares stop: and pause: with (BOOL *)onWordBoundary (a pointer). The React Native bridge cannot marshal a JS boolean to a BOOL * — it only handles value types. This crashes every time the JS wrapper calls TextToSpeech.stop(onWordBoundary).

Fix

Change the parameter type from BOOL * (pointer) to BOOL (value) in both RCT_EXPORT_METHOD declarations, and simplify the null-pointer guard to a plain boolean check:

// Before
RCT_EXPORT_METHOD(stop:(BOOL *)onWordBoundary ...)
{
    if(onWordBoundary != NULL && onWordBoundary) { ... }
}

// After
RCT_EXPORT_METHOD(stop:(BOOL)onWordBoundary ...)
{
    if(onWordBoundary) { ... }
}

Same change applied to pause:.

This restores full word-boundary stop/pause functionality. The JS wrapper (index.js) already passes onWordBoundary correctly; the bug was entirely in the native type declaration.

Testing

Tested on physical iPhone (iOS 18) with React Native 0.85.3. stop() and pause() no longer crash and correctly honour the onWordBoundary flag.

…ling crash

The RN bridge cannot marshal a JS boolean to BOOL* (pointer type).
Change both stop: and pause: RCT_EXPORT_METHOD params from (BOOL *) to (BOOL)
and simplify the null-pointer guard to a plain boolean check.

Fixes: TextToSpeech.stop(): Error while converting JavaScript argument 0
to Objective C type BOOL. Objective C type BOOL is unsupported.
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.

1 participant