Issues with iOS and openvidu-ionic-capacitor

We are using ionic 6.0 with capacitor 3.4.3 and everything works fine on web (even safari!) and android, but we are having issues with iOS (iPhone w/ ios 14.4.2) .

Our setup

We started by trying the example project, and it worked.
We even migrated the demo project to capacitor 3.4.2 to make sure that it worked.

Then we started the implementation following the guide: openvidu-ionic-capacitor - OpenVidu Docs

Here we had our first issues:
At one point the guide says to follow the “ios-specific-requirements
but this guide is written for cordova, not capacitor.
This means that is not possible to use the provided hook that automatically set some configurations, so we had to do these steps manually as written here: cordova-plugin-iosrtc/Building.md at master · cordova-rtc/cordova-plugin-iosrtc · GitHub

Continuing with the guide we arrived at the step where we need to add “src/assets/libs/adapter-4.0.1.js”.
We added it, but we also noticed that in the example it is not used!
(Actually we found a commit that removed it in the example with cordova, but the application’s soruce code for capacitor is the same)

For sure the documentation could be improved/written for capacitor.

The issue:

It seems that this.session.publish(publisher) never completes. We don’t get any error, even with iosrtc’s debug mode enabled (cordova.plugins.iosrtc.debug.enable('*', true);)

We think that it might be some issue with the configuration of capacitor’s ios project because we had to guess some steps, but we are not sure.
We even tried to see the differences between the files generated by capacitor form out project and the example project but we could not find anything obviously…

These are the logs when we try to join a call:

[Debug] Connecting websocket to URI: wss://videocall-dev.ourwebsite/openvidu?sessionId=k31O3x3e0R (src_app_modules_videocall_videocall_module_ts.js, line 13335)
[Debug] WebSocket connected to wss://videocall-dev.ourwebsite/openvidu?sessionId=k31O3x3e0R (src_app_modules_videocall_videocall_module_ts.js, line 13335)
[Debug] --------- ONCONNECTED ----------- (src_app_modules_videocall_videocall_module_ts.js, line 13335)
[Debug] Starting ping (if configured) (src_app_modules_videocall_videocall_module_ts.js, line 13335)
[Debug] Sending request: {method:"joinRoom", params: {"token":"wss://videocall-dev.ourwebsite?sessionId=k31O3x3e0R&token=tok_NAw66WfMyFaBrSGr","session":"k31O3x3e0R","platform":"Safari 11.x on Apple iPhone (iOS 14.4.2)","sdkVersion":"2.21.0","metadata":"{\"role\":\"PUBLISHER\",\"screenShare\":false,\"externalUser\":false,\"user\":{\"id\":2,\"login\":\"user\",\"firstName\":\"User primo\",\"lastName\":\"User\",\"email\":\"user@localhost\",\"imageUrl\":\"http://localhost:8080/static/13f49257-4916-4f9c-90f1-88958f8e49b7.jpeg\",\"activated\":true,\"langKey\":\"it\",\"createdBy\":\"system\",\"createdDate\":null,\"lastModifiedBy\":\"system\",\"lastModifiedDate\":\"2022-05-30T10:00:04.959487Z\",\"authorities\":[\"ROLE_USER\"],\"birthDate\":null,\"residenceCity\":null,\"organization\":null,\"department\":null,\"profession\":null,\"url\":null,\"competences\":null,\"shortBiography\":null}}","secret":"","recorder":false}} (src_app_modules_videocall_videocall_module_ts.js, line 13335)
[Debug] Response: {"id":"con_YoFntyTyA5","finalUserId":"6681EB6E2EE3C82C","createdAt":1654780936742,"metadata":"{\"role\":\"PUBLISHER\",\"screenShare\":false,\"externalUser\":false,\"user\":{\"id\":2,\"login\":\"user\",\"firstName\":\"User primo\",\"lastName\":\"User\",\"email\":\"user@localhost\",\"imageUrl\":\"http://localhost:8080/static/13f49257-4916-4f9c-90f1-88958f8e49b7.jpeg\",\"activated\":true,\"langKey\":\"it\",\"createdBy\":\"system\",\"createdDate\":null,\"lastModifiedBy\":\"system\",\"lastModifiedDate\":\"2022-05-30T10:00:04.959487Z\",\"authorities\":[\"ROLE_USER\"],\"birthDate\":null,\"residenceCity\":null,\"organization\":null,\"department\":null,\"profession\":null,\"url\":null,\"competences\":null,\"shortBiography\":null}}%/%{\n  \"userId\" : 2,\n  \"externalNickname\" : null\n}","value":[],"session":"k31O3x3e0R","version":"2.20.0","mediaServer":"kurento","record":true,"role":"PUBLISHER","coturnIp":"40.68.222.82","turnUsername":"25CN8K","turnCredential":"ptz0lm","sessionId":"8run2lmn4qtpsu9mfuo8nv067p"} (src_app_modules_videocall_videocall_module_ts.js, line 13335)
[Info] openvidu-server version: 2.20.0 (src_app_modules_videocall_videocall_module_ts.js, line 13347)
[Error] openvidu-browser (2.21.0) and openvidu-server (2.20.0) versions are incompatible. Errors are likely to occur. openvidu-browser SDK is only compatible with the same version or the immediately following minor version of an OpenVidu deployment
[Info] 'Connection' created (local) (src_app_modules_videocall_videocall_module_ts.js, line 13347)
[Log] ios (src_app_modules_videocall_videocall_module_ts.js, line 607)
[Log] settings – {audioDevice: {kind: "audioinput", deviceId: "Built-In Microphone", label: "iPhone Microphone"}, videoDevice: {kind: "videoinput", deviceId: "com.apple.avfoundation.avcapturedevice.built-in_video:1", label: "Front Camera"}, enableMicrophone: true, …} (src_app_modules_videocall_videocall_module_ts.js, line 667)
{audioDevice: {kind: "audioinput", deviceId: "Built-In Microphone", label: "iPhone Microphone"}, videoDevice: {kind: "videoinput", deviceId: "com.apple.avfoundation.avcapturedevice.built-in_video:1", label: "Front Camera"}, enableMicrophone: true, enableWebcam: true, nickname: null}Object
[Log] publisher – Publisher {userHandlerArrowHandler: WeakMap, ee: EventEmitter, videos: [], …} (src_app_modules_videocall_videocall_module_ts.js, line 680)
Publisher {userHandlerArrowHandler: WeakMap, ee: EventEmitter, videos: [], lazyLaunchVideoElementCreatedEvent: false, stream: Stream, …}Publisher
[Log] iosrtc:getUserMedia [original constraints: (user-script:21, line 4632)
{audio: true, video: {width: {ideal: 640}, height: {ideal: 480}, frameRate: {ideal: 30}}}
] +18s
[Log] iosrtc:getUserMedia [computed constraints: (user-script:21, line 4632)
{video: {width: {ideal: 640}, height: {ideal: 480}, frameRate: {ideal: 30}}, audio: {}}
] +1ms
[Log] iosrtc:getUserMedia getUserMedia() | success +17ms (user-script:21, line 4632)
[Log] iosrtc:MediaStream create() | [dataFromEvent: (user-script:21, line 4632)
{id: "F58BA36F-2DE6-4539-9F75-5C2EF3F4DB9F", audioTracks: Object, videoTracks: Object}
] +17s
[Log] iosrtc:MediaStream new MediaStream(arg) | [arg: (user-script:21, line 4632)
[] (0)
] +0ms
[Log] iosrtc:MediaStreamTrack new() | [dataFromEvent: (user-script:21, line 4632)
{readyState: "live", id: "F01CBFDC-77BA-4757-9561-116FD883FC14", kind: "audio", enabled: true, capabilities: {}, …}
] +18s
[Log] iosrtc:MediaStreamTrack new() | [dataFromEvent: (user-script:21, line 4632)
{readyState: "live", id: "B3E25D55-A012-444B-8AA5-9F1C8F4E0283", kind: "video", enabled: true, capabilities: {deviceId: "com.apple.avfoundation.avcapturedevice.built-in_video:1"}, …}
] +1ms
[Log] iosrtc:MediaStream emitConnected() +3ms (user-script:21, line 4632)
[Log] iosrtc:MediaStream getAudioTracks() +1ms (user-script:21, line 4632)
[Log] iosrtc:MediaStream getAudioTracks() +0ms (user-script:21, line 4632)
[Log] iosrtc:MediaStreamTrack enabled = true +1ms (user-script:21, line 4632)
[Log] iosrtc:MediaStream getVideoTracks() +0ms (user-script:21, line 4632)
[Log] iosrtc:MediaStream getVideoTracks() +1ms (user-script:21, line 4632)
[Log] iosrtc:MediaStreamTrack enabled = false +1ms (user-script:21, line 4632)
[Log] iosrtc:MediaStream getAudioTracks() +0ms (user-script:21, line 4632)
[Info] Audio track Content Hint set: '' (src_app_modules_videocall_videocall_module_ts.js, line 13347)
[Log] iosrtc:MediaStream getVideoTracks() +0ms (user-script:21, line 4632)
[Info] Video track Content Hint set: 'motion' (src_app_modules_videocall_videocall_module_ts.js, line 13347)
[Debug] Video srcObject [F58BA36F-2DE6-4539-9F75-5C2EF3F4DB9F] updated in stream [undefined] (src_app_modules_videocall_videocall_module_ts.js, line 13335)
[Log] iosrtc:videoElementsHandler new video element added +17s (user-script:21, line 4632)
[Log] iosrtc:videoElementsHandler observeVideo() +0ms (user-script:21, line 4632)
[Log] iosrtc:MediaStreamRenderer new() | [element:"<video>"] +17s (user-script:21, line 4632)
[Log] iosrtc:MediaStreamRenderer refresh() +2ms (user-script:21, line 4632)
[Log] iosrtc:MediaStreamRenderer refresh() | no video track yet +0ms (user-script:21, line 4632)
[Log] iosrtc:MediaStreamRenderer refresh() | [data: (user-script:21, line 4632)
{elementLeft: 0, elementTop: 0, elementWidth: 0, elementHeight: 0, videoViewWidth: 0, …}
] +0ms
[Log] iosrtc:MediaStreamRenderer render() [stream: (user-script:21, line 4632)
MediaStream {, …}
] +2ms
[Log] iosrtc:MediaStreamRenderer close() +3ms (user-script:21, line 4632)
[Log] iosrtc:MediaStreamRenderer new() | [element:"<video>"] +0ms (user-script:21, line 4632)
[Log] iosrtc:MediaStreamRenderer refresh() +1ms (user-script:21, line 4632)
[Log] iosrtc:MediaStreamRenderer refresh() | no video track yet +0ms (user-script:21, line 4632)
[Log] iosrtc:MediaStreamRenderer refresh() | [data: (user-script:21, line 4632)
{elementLeft: 0, elementTop: 0, elementWidth: 0, elementHeight: 0, videoViewWidth: 0, …}
] +0ms
[Log] iosrtc:MediaStreamRenderer render() [stream: (user-script:21, line 4632)
MediaStream {, …}
] +0ms
[Log] iosrtc:MediaStreamRenderer onEvent() | [type:videoresize, data: (user-script:21, line 4632)
{size: {width: 480, height: 640}, type: "videoresize"}
] +184ms
[Log] iosrtc:MediaStreamRenderer refresh() +1ms (user-script:21, line 4632)
[Log] iosrtc:MediaStreamRenderer refresh() | [data: (user-script:21, line 4632)
{elementLeft: 32, elementTop: 93, elementWidth: 311, elementHeight: 311, videoViewWidth: 311, …}
] +0ms

Yes, we are aware of

[Error] openvidu-browser (2.21.0) and openvidu-server (2.20.0) versions are incompatible

but right now it’s difficult for us to update the openvidu-server or downgrade openvidu-browser. We think/hope that the problem is not related to this. On the other plafroms (android/web we didn’t have any issue). In the next days we might try to upgrade openvidu-browser to 2.22 and try to connect to openvidu’s demo server that it’s also on 2.22

Do you have any hint on where the issue could be? Or suggestions on how we can debug why this.session.publish(publisher) never completes?

Thanks a lot!

Ok, just tried with openvidu-browser (2.22.0) and openvidu-server (2.22.0) but we still have the behaviour:

[Debug] Connecting websocket to URI: wss://demos.openvidu.io/openvidu?sessionId=k31O3x3e0R (src_app_modules_videocall_videocall_module_ts.js, line 13828)
[Debug] WebSocket connected to wss://demos.openvidu.io/openvidu?sessionId=k31O3x3e0R (src_app_modules_videocall_videocall_module_ts.js, line 13828)
[Debug] --------- ONCONNECTED ----------- (src_app_modules_videocall_videocall_module_ts.js, line 13828)
[Debug] Starting ping (if configured) (src_app_modules_videocall_videocall_module_ts.js, line 13828)
[Debug] Sending request: {method:"joinRoom", params: {"token":"wss://demos.openvidu.io?sessionId=k31O3x3e0R&token=tok_WM1tOcRpaieK8XzA&edition=pro&webrtcStatsInterval=30&sendBrowserLogs=debug_app","session":"k31O3x3e0R","platform":"Safari 11.x on Apple iPhone (iOS 14.4.2)","sdkVersion":"2.22.0","metadata":"{\"role\":\"PUBLISHER\",\"screenShare\":false,\"externalUser\":false,\"user\":{\"id\":2,\"login\":\"user\",\"firstName\":\"User primo\",\"lastName\":\"User\",\"email\":\"user@localhost\",\"imageUrl\":\"http://localhost:8080/static/13f49257-4916-4f9c-90f1-88958f8e49b7.jpeg\",\"activated\":true,\"langKey\":\"it\",\"createdBy\":\"system\",\"createdDate\":null,\"lastModifiedBy\":\"system\",\"lastModifiedDate\":\"2022-05-30T10:00:04.959487Z\",\"authorities\":[\"ROLE_USER\"],\"birthDate\":null,\"residenceCity\":null,\"organization\":null,\"department\":null,\"profession\":null,\"url\":null,\"competences\":null,\"shortBiography\":null}}","secret":"","recorder":false}} (src_app_modules_videocall_videocall_module_ts.js, line 13828)
[Debug] Response: {"id":"con_RTV600S7WX","finalUserId":"76ED8026A7D2600A","createdAt":1654841669638,"metadata":"{\"role\":\"PUBLISHER\",\"screenShare\":false,\"externalUser\":false,\"user\":{\"id\":2,\"login\":\"user\",\"firstName\":\"User primo\",\"lastName\":\"User\",\"email\":\"user@localhost\",\"imageUrl\":\"http://localhost:8080/static/13f49257-4916-4f9c-90f1-88958f8e49b7.jpeg\",\"activated\":true,\"langKey\":\"it\",\"createdBy\":\"system\",\"createdDate\":null,\"lastModifiedBy\":\"system\",\"lastModifiedDate\":\"2022-05-30T10:00:04.959487Z\",\"authorities\":[\"ROLE_USER\"],\"birthDate\":null,\"residenceCity\":null,\"organization\":null,\"department\":null,\"profession\":null,\"url\":null,\"competences\":null,\"shortBiography\":null}}%/%{\n  \"userId\" : 2,\n  \"externalNickname\" : null\n}","value":[],"session":"k31O3x3e0R","version":"2.22.0","mediaServer":"kurento","videoSimulcast":false,"record":true,"role":"PUBLISHER","coturnIp":"193.147.51.52","coturnPort":443,"turnUsername":"1654928069:OqFJOIrS","turnCredential":"AfjhuB+6WTr1btnKQXmZ65R5yXM=","sessionId":"abcqg33ob9q3qhos34sr07qgn1"} (src_app_modules_videocall_videocall_module_ts.js, line 13828)
[Log] STUN/TURN server IP: 193.147.51.52 (src_app_modules_videocall_videocall_module_ts.js, line 13813)
[Log] TURN temp credentials [1654928069:OqFJOIrS:AfjhuB+6WTr1btnKQXmZ65R5yXM=] (src_app_modules_videocall_videocall_module_ts.js, line 13813)
[Info] openvidu-server version: 2.22.0 (src_app_modules_videocall_videocall_module_ts.js, line 13840)
[Info] Configuring JSNLogs. (src_app_modules_videocall_videocall_module_ts.js, line 13840)
[Info] JSNLog configured. (src_app_modules_videocall_videocall_module_ts.js, line 13840)
[Info] 'Connection' created (local) (src_app_modules_videocall_videocall_module_ts.js, line 13840)
[Log] ios (src_app_modules_videocall_videocall_module_ts.js, line 13739)
[Log] settings – {audioDevice: {kind: "audioinput", deviceId: "Built-In Microphone", label: "iPhone Microphone"}, videoDevice: {kind: "videoinput", deviceId: "com.apple.avfoundation.avcapturedevice.built-in_video:1", label: "Front Camera"}, enableMicrophone: true, …} (src_app_modules_videocall_videocall_module_ts.js, line 13739)
{audioDevice: {kind: "audioinput", deviceId: "Built-In Microphone", label: "iPhone Microphone"}, videoDevice: {kind: "videoinput", deviceId: "com.apple.avfoundation.avcapturedevice.built-in_video:1", label: "Front Camera"}, enableMicrophone: true, enableWebcam: true, nickname: null}Object
[Log] publisher – Publisher {userHandlerArrowHandler: WeakMap, ee: EventEmitter, videos: [], …} (src_app_modules_videocall_videocall_module_ts.js, line 13739)
Publisher {userHandlerArrowHandler: WeakMap, ee: EventEmitter, videos: [], lazyLaunchVideoElementCreatedEvent: false, stream: Stream, …}Publisher
[Log] iosrtc:getUserMedia [original constraints: (src_app_modules_videocall_videocall_module_ts.js, line 13739)
{audio: true, video: {width: {ideal: 640}, height: {ideal: 480}, frameRate: {ideal: 30}}}
] +21s
[Log] iosrtc:getUserMedia [computed constraints: (src_app_modules_videocall_videocall_module_ts.js, line 13739)
{video: {width: {ideal: 640}, height: {ideal: 480}, frameRate: {ideal: 30}}, audio: {}}
] +5ms
[Log] iosrtc:getUserMedia getUserMedia() | success +28ms (src_app_modules_videocall_videocall_module_ts.js, line 13739)
[Log] iosrtc:MediaStream create() | [dataFromEvent: (src_app_modules_videocall_videocall_module_ts.js, line 13739)
{id: "629F89E0-D8CF-4413-99F7-5F2F6BF5440B", audioTracks: Object, videoTracks: Object}
] +20s
[Log] iosrtc:MediaStream new MediaStream(arg) | [arg: (src_app_modules_videocall_videocall_module_ts.js, line 13739)
[] (0)
] +3ms
[Log] iosrtc:MediaStreamTrack new() | [dataFromEvent: (src_app_modules_videocall_videocall_module_ts.js, line 13739)
{readyState: "live", id: "C00704B5-925B-4106-A6FB-DB1445436117", kind: "audio", enabled: true, capabilities: {}, …}
] +21s
[Log] iosrtc:MediaStreamTrack new() | [dataFromEvent: (src_app_modules_videocall_videocall_module_ts.js, line 13739)
{readyState: "live", id: "89E5E82B-4B3D-457B-848D-4A77B6A60435", kind: "video", enabled: true, capabilities: {deviceId: "com.apple.avfoundation.avcapturedevice.built-in_video:1"}, …}
] +2ms
[Log] iosrtc:MediaStream emitConnected() +9ms (src_app_modules_videocall_videocall_module_ts.js, line 13739)
[Log] iosrtc:MediaStream getAudioTracks() +3ms (src_app_modules_videocall_videocall_module_ts.js, line 13739)
[Log] iosrtc:MediaStream getAudioTracks() +0ms (src_app_modules_videocall_videocall_module_ts.js, line 13739)
[Log] iosrtc:MediaStreamTrack enabled = true +6ms (src_app_modules_videocall_videocall_module_ts.js, line 13739)
[Log] iosrtc:MediaStream getVideoTracks() +2ms (src_app_modules_videocall_videocall_module_ts.js, line 13739)
[Log] iosrtc:MediaStream getVideoTracks() +0ms (src_app_modules_videocall_videocall_module_ts.js, line 13739)
[Log] iosrtc:MediaStreamTrack enabled = false +1ms (src_app_modules_videocall_videocall_module_ts.js, line 13739)
[Log] iosrtc:MediaStream getAudioTracks() +1ms (src_app_modules_videocall_videocall_module_ts.js, line 13739)
[Info] Audio track Content Hint set: '' (src_app_modules_videocall_videocall_module_ts.js, line 13840)
[Log] iosrtc:MediaStream getVideoTracks() +0ms (src_app_modules_videocall_videocall_module_ts.js, line 13739)
[Info] Video track Content Hint set: 'motion' (src_app_modules_videocall_videocall_module_ts.js, line 13840)
[Debug] Video srcObject [629F89E0-D8CF-4413-99F7-5F2F6BF5440B] updated in stream [undefined] (src_app_modules_videocall_videocall_module_ts.js, line 13828)
[Log] iosrtc:videoElementsHandler new video element added +20s (src_app_modules_videocall_videocall_module_ts.js, line 13739)
[Log] iosrtc:videoElementsHandler observeVideo() +1ms (src_app_modules_videocall_videocall_module_ts.js, line 13739)
[Log] iosrtc:MediaStreamRenderer new() | [element:"<video>"] +20s (src_app_modules_videocall_videocall_module_ts.js, line 13739)
[Log] iosrtc:MediaStreamRenderer refresh() +3ms (src_app_modules_videocall_videocall_module_ts.js, line 13739)
[Log] iosrtc:MediaStreamRenderer refresh() | no video track yet +1ms (src_app_modules_videocall_videocall_module_ts.js, line 13739)
[Log] iosrtc:MediaStreamRenderer refresh() | [data: (src_app_modules_videocall_videocall_module_ts.js, line 13739)
{elementLeft: 0, elementTop: 0, elementWidth: 0, elementHeight: 0, videoViewWidth: 0, …}
] +1ms
[Log] iosrtc:MediaStreamRenderer render() [stream: (src_app_modules_videocall_videocall_module_ts.js, line 13739)
MediaStream {, …}
] +1ms
[Log] iosrtc:MediaStreamRenderer close() +6ms (src_app_modules_videocall_videocall_module_ts.js, line 13739)
[Log] iosrtc:MediaStreamRenderer new() | [element:"<video>"] +0ms (src_app_modules_videocall_videocall_module_ts.js, line 13739)
[Log] iosrtc:MediaStreamRenderer refresh() +2ms (src_app_modules_videocall_videocall_module_ts.js, line 13739)
[Log] iosrtc:MediaStreamRenderer refresh() | no video track yet +2ms (src_app_modules_videocall_videocall_module_ts.js, line 13739)
[Log] iosrtc:MediaStreamRenderer refresh() | [data: (src_app_modules_videocall_videocall_module_ts.js, line 13739)
{elementLeft: 0, elementTop: 0, elementWidth: 0, elementHeight: 0, videoViewWidth: 0, …}
] +1ms
[Log] iosrtc:MediaStreamRenderer render() [stream: (src_app_modules_videocall_videocall_module_ts.js, line 13739)
MediaStream {, …}
] +1ms
[Log] iosrtc:MediaStreamRenderer onEvent() | [type:videoresize, data: (src_app_modules_videocall_videocall_module_ts.js, line 13739)
{size: {height: 640, width: 480}, type: "videoresize"}
] +137ms
[Log] iosrtc:MediaStreamRenderer refresh() +3ms (src_app_modules_videocall_videocall_module_ts.js, line 13739)

BTW we noticed that our this._streamManager.stream.videoDimensions called inside applyIosIonicVideoAttributes is undefined. I don’t know if this could be and issue

in fact our this._streamManager.stream object is this:

Hi, we are going to update this tutorial.
I’ll keep you posted.

1 Like

Thanks :slight_smile:
Do you have a rough estimate on when will this be completed so that I can organise my work? (a couple of days/ a couple of weeks/ a couple of months…)

Not sure if this can help, but we have found that in our case this condition

!!this.videoReference.videoWidth

is never true, in fact this.videoReference.videoWidth is always 0

After much debugging we partially solved our problems!
We are kind rushing to deliver this feature so I’ll be brief. I’ll try to explain better when we have everything working :slight_smile:

How we solved our problem:

  • we noticed that we where using an ion-content inside anther ion-content as a wrapper for our videocall component. We switched our outer ion-content with a div. As per ionic’s doc: There should only be one content in a single view.

  • we added [scrollEvents]="true" (ionScroll)="refreshVideos()" ad described on openvidu’s doc

After this we where able to see other partecipant’s streams but the pubblisher’s stream was not working and we were having the infamous error Error for 'Subscriber' (str_CAM_MKqg_con_XnkiKvNdM8) while trying to subscribe: InvalidStateError: Media stream has no audio tracks

So we started debugging openvidu line by line and discovered that the error was throw by the hark library used by openvidu. Specifically here: audioContext.createMediaStreamSource(stream);

Specifically the “stack trace” was
publish
initWebRtcPeerSend
initHarkEvents
enableHarkSpeakingEvent
setHarkListenerIfNotExists
hark(this.mediaStream, harkOptions);
audioContext.createMediaStreamSource(stream)

So we removed from our code the lines related to speaker recognition:

streamManager.on('publisherStartSpeaking', () => {
            this.publisherSpeaking$.next(true);
        });
        streamManager.on('publisherStopSpeaking', () => {
            this.publisherSpeaking$.next(false);
        });

And everything worked.
This is a workaround but it’s fine for us for now.

I just want to point out that the error InvalidStateError: Media stream has no audio tracks has been a bit misleading for us because when we printed our media streams’ audio tracks it correctly contained the iPhone’s microphone :man_shrugging:

Maybe @pabloFuente has some idea on why we are expecting this issue with hark… or do you suggest opening an issue on hark’s repo?