[Bug]: webRTC not working properly on ios device
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 38/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- ios, javascript
调研方向
从链接的 capacitorTest 项目及其 capacitor.config 和 vite.config.js 开始,并在所需的 HTTPS 配置下运行 npx vite --port 5173。在 iOS 设备上复现首次 WebRTC 音频播放,然后跟踪 Capacitor iOS/WKWebView 路径;当初始播放流畅且没有中断时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
Capacitor Version 7.4.3
INTRODUCTION
Hello from Australia!
My name is Scott and I'm using the sdk @openai/agents-realtime and I'm having a huge problem with it in the capacitor app.
Basically it works perfectly on the android device, google chrome browser and safari browser but on the ios device i have a small bug that i cannot erradicate.
Basically how the app works is that a webRTC is created on the client side and it streams audio from the client side to openAI when the client speaks into the microphone openAI replies back in audio. It's awsome.
THE PROBLEM
The problem I'm having is that when the audio first starts to play on the ios device it stops then starts then stops and starts on the first play. After the first play, it works perfectly.
This is definately a capacitor bug because i can get it to work perfectly in the safari and chrome browsers and on an capacitor app on an android device but it malfunctions on the first audio play on a capacitor app on an ios device.
THE LIKELY CAUSE
The reason for this error is because capacitor apps for ios use a special wrapper (WKWebView) that mimics safari and the reason this error doesn't occur in the safari browser is because safari's audio handling has been built to handle this situation but the wrappers (WKWebView) that are used in frameworks like capacitor haven't been just yet, let me explain this in more detail.......
Safari (the full browser) runs in a long-lived WebKit process that usually has the AVAudioSession already active (or quickly activated) after a user gesture. When WebRTC/audio starts, Safari often has the route + sample rate “hot,” so first playback is smooth.
WKWebView on the otherhand (the wrapper that capacitor and many others are using atm) starts cold and so first audio play from a webRTC will stop and start and stop and start a few times on first play as the audio sets up from scratch each time on first play. So to fix the error it would be pretty easy on your end because all you really need to do is pre-activate the AVAudioSession inside capacitor.
RESOURCES
The sdk is below but in the project I am giving you via github the sdk is provided via cdn so you don't have to install it but the documentation for this sdk is below if you still want to read it:
https://openai.github.io/openai-agents-js/guides/voice-agents/quickstart/
I made a youtube video showing you how it works on everything except ios device.
I have already made you a simple project in capacitor, javascript and html using this library from openAI and you can use this project to debug the problem with capacitor only you will need to create your own openAI client secret key from the openAI console here;
https://platform.openai.com/api-keys
Also because the cdn sdk is using webRTC, the app must be hosted on a https local server not http so therefore you will need to create the two certificates to enable this using the unix comands below from the root directory:
-
Install mkcert (once)
brew install mkcert -
Install the local root CA (once)
mkcert -install -
Create a cert specifically for your IP
mkcert -cert-file ip.pem -key-file ip-key.pem 123.456.78.9 (your ip address on your machine)
I have already completed the imports for these two certificates so you just need to make them and keep them in the root directory.
i have already made all the configurations for ios and android for you to run this project on your own device via xcode and android studio and I have already set up the capacitor.config and vite.config.js files only you will need to put your own ip address there as i have still got mine there.
Here is the project I have built for you so you can use it to debug the issue:
https://github.com/scottywm/capacitorTest.git
To run the project you need to use vite on port 5173, just run the command below from the route directory:
npx vite --port 5173
If you need help getting the project started and have other questions I'm happy to chat with you over a zoom meeting if you like. Just email me at [email protected].
Please action this asap because i've been working on my app all year and im almost finished and now this bug in capacitor is a fatal flaw so please fix it.
Other API Details
Platforms Affected
- iOS
- Android
- Web
Current Behavior
The capacitor app works perfectly on an android device and i can even get it to work perfectly in the chrome and safari browser but when I use capacitor to make it into an app it malfunctions on an ios device when the audio first starts playing. The first audio play on an ios device stops then starts then stops then starts. This is terrible!
Expected Behavior
The audio must play smoothly on both ios and android devices without stops and starts.
Project Reproduction
https://github.com/scottywm/capacitorTest.git
Additional Information
I've been working on this app for nine months staright now and this error is fatal so it must get fixed ASAP!!!
- 主要语言
- TypeScript
- 星标
- 17.1k
- 派生
- 1.3k
- 平均合并
- 1 天 22 小时
- 30 天内合并 PR
- 26
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ionic-team/capacitor 的其他 Issue
-
triage
难度 2/5 1-3 小时 新手友好度 76/100
ionic-team/capacitor#8759 ·
维护者通常 1 天内回复
-
[Bug]: Plugin call after navigation can be answered before reply proxy is updated可能已有人在做 @MateStrysewske 于 71 天前认领。 未关闭triage
难度 2/5 1-3 小时 新手友好度 84/100
ionic-team/capacitor#8616 ·
维护者通常 1 天内回复
-
help wanted
难度 2/5 1-3 小时 新手友好度 68/100
ionic-team/capacitor#8574 · 3 条评论 ·
维护者通常 1 天内回复
-
SystemBars: safe area CSS injection throws "Cannot read properties of null" on startup (Android 16)可能已有人在做 @kttalley 于 62 天前认领。 未关闭triage
难度 2/5 1-3 小时 新手友好度 78/100
ionic-team/capacitor#8530 · 2 条评论 ·
维护者通常 1 天内回复
-
fix(android): remove unchecked Java compilation warnings可能已有人在做 @Ajamuar 于 15 天前认领。 未关闭triage
难度 2/5 1-3 小时 新手友好度 78/100
ionic-team/capacitor#8529 · 1 条评论 ·
维护者通常 1 天内回复
查看 ionic-team/capacitor 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
prio:low scope:world
难度 2/5 1-3 小时 新手友好度 83/100
OliverRomhagen/vrigstad-joyride#849 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
genfeedai/genfeed.ai#11916 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
erkamyaman/rust-anything#1153 ·
维护者通常 1 天内回复
-
The Phase 5 report says 0.3.0 waits for the live check可能已有人在做 @fzn0x 今天认领。 未关闭documentation
难度 1/5 1 小时以内 新手友好度 85/100
维护者通常 1 天内回复