Skip to content
This repository was archived by the owner on May 6, 2022. It is now read-only.
This repository was archived by the owner on May 6, 2022. It is now read-only.

"Illegal callback invocation error", "Spokestack error during initialize.", and app crash when calling Spokestack.initialize() on first load. No issues on subsequent loads. (iOS only) #105

@cdmoss

Description

@cdmoss

Describe the bug

As the title describes, here is the the console output during the first load of the app on an iOS device:

2021-11-16 13:08:06.096795-0700 mobile[4246:3045067] [native] Illegal callback invocation from native module. This callback type only permits a single invocation from native code.
2021-11-16 13:08:06.096902-0700 mobile[4246:3045068] [native] Illegal callback invocation from native module. This callback type only permits a single invocation from native code.
2021-11-16 13:08:06.423242-0700 mobile[4246:3044487] [javascript] [Error: Spokestack error during initialize.]
2021-11-16 13:08:08.461274-0700 mobile[4246:3044487] [javascript] Possible Unhandled Promise Rejection (id: 0):
Error: Speech Pipeline is not initialized. Call Spokestack.initialize() first.

followed by the app crashing.

Strangely, after reloading the app, these issues do not occur and the app works fine.

Here is the code initalizing Spokestack:

useEffect(() => {
        const initializeSpokestack = () => {
            Spokestack.addEventListener('activate', () => {
                console.log('Spokestack activated')
                if (!navigation.isFocused()) {
                    navigation.navigate('Map')
                }
                if (AppState.currentState != 'active') {
                    Linking.openURL("cnp.mobile://")
                }
                if (!voiceVisible) {
                    toggleVoiceVisible(true)   
                }
                setSpeechResult('')
                setListening(true)
            });
            Spokestack.addEventListener('deactivate', () => {
                console.log('Spokestack deactivated')
                setListening(false)
            })
            Spokestack.addEventListener('recognize', ({transcript}) => {
                console.log('Spokestack finished recognizing')
                setPartialSpeechResult('')
                setSpeechResult((transcript as string).trim().toLowerCase())
                setPreviousResult(transcript)
            })
            Spokestack.addEventListener('partial_recognize', ({transcript}) => {
                console.log('Spokestack recognizing')
                setPartialSpeechResult(transcript)
            })  

            try {
                Spokestack.initialize(
                    SPOKESTACK_ID, // account id
                    SPOKESTACK_TOKEN, // api token
                    {
                        pipeline: {
                            profile: PipelineProfile.TFLITE_WAKEWORD_NATIVE_ASR
                        },
                        wakeword: {
                            filter: require('../../../../assets/tflites/filter.tflite'),
                            detect: require('../../../../assets/tflites/detect.tflite'),
                            encode: require('../../../../assets/tflites/encode.tflite'),
                        },
                    }
                ).then(Spokestack.start).catch(error => console.log(error))
            } catch (error) {
                console.log(error)
            }
        }
        initializeSpokestack()

        return () => {
            Spokestack.removeAllListeners();
        };
    }, []);

Your environment

  • Version of react-native-spokestack: 6.1.4
  • Version of react-native: 0.64.3
  • Device and OS version: iPhone, iOS 14

Expected behavior

The app should not crash on first load.

Actual behavior

The app crashes on first load with aforementioned errors.

Has anyone encountered this sort of error, or know what could cause it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions