[Android] Native Crash (SIGSEGV) injecting Bitmap from PixelCopy into WebRTC VideoSource (GetStream)
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
- Tipo di issue
- Bug
- Chiarezza
- Da chiarire
- Stato di attività
- Tranquilla
- Ambito
- audio-video-rtc, mobile-dev
Direzione di ricerca
Inizia con il PixelCopy callback e con gli entry point org.webrtc.NV21Buffer, VideoFrame e VideoSource capturerObserver mostrati nel report. Confronta gli approcci JavaI420Buffer, ByteBuffer diretto, SurfaceTextureHelper e HandlerThread, quindi verifica che la pipeline Bitmap personalizzata non causi più il SIGSEGV nativo durante l’invio dei frames.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Hello everyone. I'm building a hybrid streaming app where I need to broadcast via RTMP (using the device's camera) and simultaneously establish a WebRTC P2P connection. Since Android doesn't allow two camera clients simultaneously, I'm trying to create a custom VideoCapturer that captures the RTMP SurfaceView using PixelCopy and feeds those frames into WebRTC.
I'm using: implementation("io.getstream:stream-webrtc-android:1.3.1")
The Issue:
The P2P connection (IceConnectionState.CONNECTED) establishes perfectly. However, the moment the WebRTC engine tries to process my custom injected frames to send them over the network, the app suffers a silent Native Crash (SIGSEGV). I suspect it's a memory violation regarding how I'm allocating the byte array or a thread context issue with SurfaceTextureHelper.
My current approach (Simplified):
Kotlin
// I have an active SurfaceView rendering the local camera.
// I run this at 15 FPS using a Handler.
PixelCopy.request(surfaceView, bitmapOriginal, { result ->
if (result == PixelCopy.SUCCESS) {
// 1. Scale down to avoid massive memory usage
val scaledBitmap = Bitmap.createScaledBitmap(bitmapOriginal, 320, 240, true)
// 2. Convert Bitmap to NV21 ByteArray (Custom math method)
val nv21Bytes = convertBitmapToNV21(scaledBitmap)
// 3. Inject into WebRTC
val timestampNs = System.nanoTime()
val buffer = org.webrtc.NV21Buffer(nv21Bytes, 320, 240, null)
val videoFrame = org.webrtc.VideoFrame(buffer, 0, timestampNs)
// videoSource is my org.webrtc.VideoSource
videoSource?.capturerObserver?.onFrameCaptured(videoFrame)
videoFrame.release()
}
}, myHandler)
My Questions:
What is the thread-safe and memory-safe (JNI-compliant) way to convert an Android Bitmap into a WebRTC VideoFrame using the GetStream library?
Should I be using JavaI420Buffer.allocate() or a direct ByteBuffer instead of a standard Kotlin ByteArray for the NV21Buffer to prevent the C++ segfault?
Do I strictly need to wrap this PixelCopy loop inside a SurfaceTextureHelper thread, or is a standard Android HandlerThread sufficient if I'm just pushing byte arrays?
Any guidance or snippet on how to properly implement a custom Bitmap to VideoFrame pipeline without crashing the native lib would be hugely appreciated!
- Lingua principale
- Kotlin
- Stelle
- 884
- Fork
- 108
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di GetStream/webrtc-android
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 30/100
GetStream/webrtc-android#323 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
GetStream/webrtc-android#319 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
GetStream/webrtc-android#317 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
GetStream/webrtc-android#316 · 4 commenti ·
-
Audio sourceAperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 20/100
GetStream/webrtc-android#315 ·
Tutte le issue di GetStream/webrtc-android
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
[Rust][Flaky Test] multiple_deadlines_fire_in_order asserts a wall-clock gap instead of firing orderApertaCI/CD ⚒️ Flaky-tests 🐦
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
valkey-io/valkey-glide#7255 ·
I maintainer di solito rispondono entro 3 giorni
-
story
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
home-assistant/android#7548 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno