Skip to content

Commit

Permalink
fix(ios): avoid emitting error events after "end" event has been emitted
Browse files Browse the repository at this point in the history
  • Loading branch information
jamsch committed Sep 5, 2024
1 parent c6df79c commit 31a46a6
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 53 deletions.
21 changes: 21 additions & 0 deletions example/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,27 @@ podfile_properties = JSON.parse(File.read(File.join(__dir__, 'Podfile.properties
ENV['RCT_NEW_ARCH_ENABLED'] = podfile_properties['newArchEnabled'] == 'true' ? '1' : '0'
ENV['EX_DEV_CLIENT_NETWORK_INSPECTOR'] = podfile_properties['EX_DEV_CLIENT_NETWORK_INSPECTOR']

use_autolinking_method_symbol = ('use' + '_native' + '_modules!').to_sym
origin_autolinking_method = self.method(use_autolinking_method_symbol)
self.define_singleton_method(use_autolinking_method_symbol) do |*args|
if ENV['EXPO_UNSTABLE_CORE_AUTOLINKING'] == '1'
Pod::UI.puts('Using expo-modules-autolinking as core autolinking source'.green)
config_command = [
'node',
'--no-warnings',
'--eval',
'require(require.resolve(\'expo-modules-autolinking\', { paths: [require.resolve(\'expo/package.json\')] }))(process.argv.slice(1))',
'react-native-config',
'--json',
'--platform',
'ios'
]
origin_autolinking_method.call(config_command)
else
origin_autolinking_method.call()
end
end

platform :ios, podfile_properties['ios.deploymentTarget'] || '13.4'
install! 'cocoapods',
:deterministic_uuids => false
Expand Down
26 changes: 13 additions & 13 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ PODS:
- ReactCommon/turbomodule/core
- EXConstants (16.0.2):
- ExpoModulesCore
- Expo (51.0.30):
- Expo (51.0.32):
- ExpoModulesCore
- ExpoAsset (10.0.10):
- ExpoModulesCore
- ExpoFileSystem (17.0.1):
- ExpoModulesCore
- ExpoFont (12.0.9):
- ExpoFont (12.0.10):
- ExpoModulesCore
- ExpoKeepAwake (13.0.2):
- ExpoModulesCore
- ExpoModulesCore (1.12.22):
- ExpoModulesCore (1.12.24):
- DoubleConversion
- glog
- hermes-engine
Expand All @@ -39,7 +39,7 @@ PODS:
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- ExpoSpeechRecognition (0.2.14):
- ExpoSpeechRecognition (0.2.15):
- ExpoModulesCore
- EXSplashScreen (0.27.5):
- DoubleConversion
Expand All @@ -66,9 +66,9 @@ PODS:
- FBLazyVector (0.74.5)
- fmt (9.1.0)
- glog (0.3.5)
- hermes-engine (0.74.3):
- hermes-engine/Pre-built (= 0.74.3)
- hermes-engine/Pre-built (0.74.3)
- hermes-engine (0.74.5):
- hermes-engine/Pre-built (= 0.74.5)
- hermes-engine/Pre-built (0.74.5)
- RCT-Folly (2024.01.01.00):
- boost
- DoubleConversion
Expand Down Expand Up @@ -1437,18 +1437,18 @@ SPEC CHECKSUMS:
DoubleConversion: 76ab83afb40bddeeee456813d9c04f67f78771b5
EXAV: afa491e598334bbbb92a92a2f4dd33d7149ad37f
EXConstants: 409690fbfd5afea964e5e9d6c4eb2c2b59222c59
Expo: 61b2953ad6afa979729f639c5992c182e8eb9040
Expo: 33132a667698a3259a4e6c0af1b4936388e5fa33
ExpoAsset: 323700f291684f110fb55f0d4022a3362ea9f875
ExpoFileSystem: 80bfe850b1f9922c16905822ecbf97acd711dc51
ExpoFont: e7f2275c10ca8573c991e007329ad6bf98086485
ExpoFont: 00756e6c796d8f7ee8d211e29c8b619e75cbf238
ExpoKeepAwake: 3b8815d9dd1d419ee474df004021c69fdd316d08
ExpoModulesCore: ccb0f619a6114b76c6a86224a52a77f5db5f1998
ExpoSpeechRecognition: 58538c1b083bfc28ee2d9531ad264d664d456a03
ExpoModulesCore: a113755f96c40590671f01cfcdce8ebdf0cf5f83
ExpoSpeechRecognition: 8dd88aa1af16251924232f0b90bed0bd90a7835a
EXSplashScreen: a7e8d13c476f9937e39d654af4235758b567a1be
FBLazyVector: ac12dc084d1c8ec4cc4d7b3cf1b0ebda6dab85af
fmt: 4c2741a687cc09f0634a2e2c72a838b99f1ff120
glog: fdfdfe5479092de0c4bdbebedd9056951f092c4f
hermes-engine: 1f547997900dd0752dc0cc0ae6dd16173c49e09b
hermes-engine: 8c1577f3fdb849cbe7729c2e7b5abc4b845e88f8
RCT-Folly: 02617c592a293bd6d418e0a88ff4ee1f88329b47
RCTDeprecation: 3afceddffa65aee666dafd6f0116f1d975db1584
RCTRequired: ec1239bc9d8bf63e10fb92bd8b26171a9258e0c1
Expand Down Expand Up @@ -1499,6 +1499,6 @@ SPEC CHECKSUMS:
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
Yoga: 2246eea72aaf1b816a68a35e6e4b74563653ae09

PODFILE CHECKSUM: 3310afcf7f865ca9740f949c34eec5ae855777c6
PODFILE CHECKSUM: ceec9518dac8a3c13e167f58439e04a010b51688

COCOAPODS: 1.15.2
32 changes: 16 additions & 16 deletions example/ios/expospeechrecognitionexample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
13B07FBC1A68108700A75B9A /* AppDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.mm */; };
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
283EB900409B50244647361C /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = E8A36AE903FBB62C40B7E02B /* PrivacyInfo.xcprivacy */; };
3C2C6067777F4D7888829EFB /* noop-file.swift in Sources */ = {isa = PBXBuildFile; fileRef = 86E5BC3716734270BD717EF8 /* noop-file.swift */; };
3E461D99554A48A4959DE609 /* SplashScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AA286B85B6C04FC6940260E9 /* SplashScreen.storyboard */; };
666E82030F000651F3096310 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = DB2E5F3A0BD0D38175C4D15E /* PrivacyInfo.xcprivacy */; };
96905EF65AED1B983A6B3ABC /* libPods-expospeechrecognitionexample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 58EEBF8E8E6FB1BC6CAF49B5 /* libPods-expospeechrecognitionexample.a */; };
B18059E884C0ABDD17F3DC3D /* ExpoModulesProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAC715A2D49A985799AEE119 /* ExpoModulesProvider.swift */; };
B7CC87D3B2034F53B76C7DC9 /* noop-file.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0E757E34B544218AFE2693F /* noop-file.swift */; };
BB2F792D24A3F905000567C9 /* Expo.plist in Resources */ = {isa = PBXBuildFile; fileRef = BB2F792C24A3F905000567C9 /* Expo.plist */; };
/* End PBXBuildFile section */

Expand All @@ -28,12 +28,12 @@
58EEBF8E8E6FB1BC6CAF49B5 /* libPods-expospeechrecognitionexample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-expospeechrecognitionexample.a"; sourceTree = BUILT_PRODUCTS_DIR; };
6C2E3173556A471DD304B334 /* Pods-expospeechrecognitionexample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-expospeechrecognitionexample.debug.xcconfig"; path = "Target Support Files/Pods-expospeechrecognitionexample/Pods-expospeechrecognitionexample.debug.xcconfig"; sourceTree = "<group>"; };
7A4D352CD337FB3A3BF06240 /* Pods-expospeechrecognitionexample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-expospeechrecognitionexample.release.xcconfig"; path = "Target Support Files/Pods-expospeechrecognitionexample/Pods-expospeechrecognitionexample.release.xcconfig"; sourceTree = "<group>"; };
86E5BC3716734270BD717EF8 /* noop-file.swift */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 4; includeInIndex = 0; lastKnownFileType = sourcecode.swift; name = "noop-file.swift"; path = "expospeechrecognitionexample/noop-file.swift"; sourceTree = "<group>"; };
AA286B85B6C04FC6940260E9 /* SplashScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = SplashScreen.storyboard; path = expospeechrecognitionexample/SplashScreen.storyboard; sourceTree = "<group>"; };
BB2F792C24A3F905000567C9 /* Expo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Expo.plist; sourceTree = "<group>"; };
C0E757E34B544218AFE2693F /* noop-file.swift */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 4; includeInIndex = 0; lastKnownFileType = sourcecode.swift; name = "noop-file.swift"; path = "expospeechrecognitionexample/noop-file.swift"; sourceTree = "<group>"; };
C4FBBC72942A40C6AED5D237 /* expospeechrecognitionexample-Bridging-Header.h */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 4; includeInIndex = 0; lastKnownFileType = sourcecode.c.h; name = "expospeechrecognitionexample-Bridging-Header.h"; path = "expospeechrecognitionexample/expospeechrecognitionexample-Bridging-Header.h"; sourceTree = "<group>"; };
DB2E5F3A0BD0D38175C4D15E /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; includeInIndex = 1; name = PrivacyInfo.xcprivacy; path = expospeechrecognitionexample/PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
E8A36AE903FBB62C40B7E02B /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; includeInIndex = 1; name = PrivacyInfo.xcprivacy; path = expospeechrecognitionexample/PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
F8F2B138B2864164A22FB241 /* expospeechrecognitionexample-Bridging-Header.h */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 4; includeInIndex = 0; lastKnownFileType = sourcecode.c.h; name = "expospeechrecognitionexample-Bridging-Header.h"; path = "expospeechrecognitionexample/expospeechrecognitionexample-Bridging-Header.h"; sourceTree = "<group>"; };
FAC715A2D49A985799AEE119 /* ExpoModulesProvider.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ExpoModulesProvider.swift; path = "Pods/Target Support Files/Pods-expospeechrecognitionexample/ExpoModulesProvider.swift"; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand All @@ -59,9 +59,9 @@
13B07FB61A68108700A75B9A /* Info.plist */,
13B07FB71A68108700A75B9A /* main.m */,
AA286B85B6C04FC6940260E9 /* SplashScreen.storyboard */,
C0E757E34B544218AFE2693F /* noop-file.swift */,
C4FBBC72942A40C6AED5D237 /* expospeechrecognitionexample-Bridging-Header.h */,
DB2E5F3A0BD0D38175C4D15E /* PrivacyInfo.xcprivacy */,
86E5BC3716734270BD717EF8 /* noop-file.swift */,
F8F2B138B2864164A22FB241 /* expospeechrecognitionexample-Bridging-Header.h */,
E8A36AE903FBB62C40B7E02B /* PrivacyInfo.xcprivacy */,
);
name = expospeechrecognitionexample;
sourceTree = "<group>";
Expand All @@ -75,7 +75,7 @@
name = Frameworks;
sourceTree = "<group>";
};
44E1F19D9D084508A6E9D971 /* Resources */ = {
6C2D907D40E74C2FBE1F7EBA /* Resources */ = {
isa = PBXGroup;
children = (
);
Expand All @@ -99,7 +99,7 @@
2D16E6871FA4F8E400B85C8A /* Frameworks */,
D65327D7A22EEC0BE12398D9 /* Pods */,
D7E4C46ADA2E9064B798F356 /* ExpoModulesProviders */,
44E1F19D9D084508A6E9D971 /* Resources */,
6C2D907D40E74C2FBE1F7EBA /* Resources */,
);
indentWidth = 2;
sourceTree = "<group>";
Expand Down Expand Up @@ -156,13 +156,13 @@
buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "expospeechrecognitionexample" */;
buildPhases = (
08A4A3CD28434E44B6B9DE2E /* [CP] Check Pods Manifest.lock */,
F01D98036667962292A15DD8 /* [Expo] Configure project */,
96600AB1AE731577DDB13C69 /* [Expo] Configure project */,
13B07F871A680F5B00A75B9A /* Sources */,
13B07F8C1A680F5B00A75B9A /* Frameworks */,
13B07F8E1A680F5B00A75B9A /* Resources */,
00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */,
800E24972A6A228C8D4807E9 /* [CP] Copy Pods Resources */,
16AC529AFB660315FF286353 /* [CP] Embed Pods Frameworks */,
1CC2B23E9F18318C4B8D9930 /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
Expand Down Expand Up @@ -212,7 +212,7 @@
BB2F792D24A3F905000567C9 /* Expo.plist in Resources */,
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */,
3E461D99554A48A4959DE609 /* SplashScreen.storyboard in Resources */,
666E82030F000651F3096310 /* PrivacyInfo.xcprivacy in Resources */,
283EB900409B50244647361C /* PrivacyInfo.xcprivacy in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -256,7 +256,7 @@
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
16AC529AFB660315FF286353 /* [CP] Embed Pods Frameworks */ = {
1CC2B23E9F18318C4B8D9930 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
Expand Down Expand Up @@ -298,7 +298,7 @@
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-expospeechrecognitionexample/Pods-expospeechrecognitionexample-resources.sh\"\n";
showEnvVarsInLog = 0;
};
F01D98036667962292A15DD8 /* [Expo] Configure project */ = {
96600AB1AE731577DDB13C69 /* [Expo] Configure project */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -327,7 +327,7 @@
13B07FBC1A68108700A75B9A /* AppDelegate.mm in Sources */,
13B07FC11A68108700A75B9A /* main.m in Sources */,
B18059E884C0ABDD17F3DC3D /* ExpoModulesProvider.swift in Sources */,
B7CC87D3B2034F53B76C7DC9 /* noop-file.swift in Sources */,
3C2C6067777F4D7888829EFB /* noop-file.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
39 changes: 22 additions & 17 deletions example/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
},
"dependencies": {
"babel-plugin-module-resolver": "^5.0.2",
"expo": "~51.0.28",
"expo": "~51.0.31",
"expo-asset": "~10.0.10",
"expo-av": "~14.0.6",
"expo-av": "~14.0.7",
"expo-build-properties": "~0.12.5",
"expo-file-system": "~17.0.1",
"expo-splash-screen": "~0.27.5",
Expand Down
6 changes: 4 additions & 2 deletions ios/ExpoSpeechRecognizer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,10 @@ actor ExpoSpeechRecognizer: ObservableObject {
if let error: Error {
// TODO: don't emit no-speech if there were already interim results
Task { @MainActor in
errorHandler(error)
if await task != nil {
// Don't emit any errors after the task has finished
errorHandler(error)
}
}
}

Expand Down Expand Up @@ -676,7 +679,6 @@ actor ExpoSpeechRecognizer: ObservableObject {
// Stop listening when the timer fires
// This will finish the current task and emit the final result (or a no-speech event)
await self?.stopListening()

}
}
}
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "expo-speech-recognition",
"version": "0.2.15",
"version": "0.2.16",
"description": "Speech Recognition for React Native Expo projects",
"main": "build/index.js",
"types": "build/index.d.ts",
Expand Down

0 comments on commit 31a46a6

Please sign in to comment.