scrcpy icon indicating copy to clipboard operation
scrcpy copied to clipboard

Connection TCPIP: android.media.MediaCodec.native_dequeueOutputBuffer [scrcpy 1.24]

Open nikolai-ivanov opened this issue 2 years ago • 4 comments

  • [x] I have read the FAQ.
  • [x] I have searched in existing issues.
  • [x] I have tried https://github.com/Genymobile/scrcpy/blob/master/FAQ.md#exception

Environment

  • OS: macOS 12.4 (chip M1)
  • scrcpy version: 1.24
  • SDL: 2.0.22 / 2.0.22
  • libavcodec: 59.18.100 / 59.18.100
  • libavformat: 59.16.100 / 59.16.100
  • libavutil: 57.17.100 / 57.17.100
  • libusb: - / 1.0.2
  • installation method: brew
  • device model: Generic Android-x86_64
  • Android version: 11

Describe the bug Device connected via tcpip 5555

scrcpy 
scrcpy 1.24 <https://github.com/Genymobile/scrcpy>
/opt/homebrew/Cellar/scrcpy/1.24/share...ped. 59.1 MB/s (41159 bytes in 0.001s)
[server] INFO: Device: unknown Generic Android-x86_64 (Android 11)
[server] ERROR: Encoding error: java.lang.IllegalStateException: null
[server] INFO: Retrying with -m2560...
[server] ERROR: Encoding error: java.lang.IllegalStateException: null
[server] INFO: Retrying with -m1920...
2022-07-05 13:41:58.014 scrcpy[13923:6436890] INFO: Renderer: metal
2022-07-05 13:41:58.032 scrcpy[13923:6436890] INFO: Initial texture: 2160x3840
[server] ERROR: Encoding error: java.lang.IllegalStateException: null
[server] INFO: Retrying with -m1600...
[server] ERROR: Encoding error: java.lang.IllegalStateException: null
[server] INFO: Retrying with -m1280...
[server] ERROR: Encoding error: java.lang.IllegalStateException: null
[server] INFO: Retrying with -m1024...
[server] ERROR: Encoding error: java.lang.IllegalStateException: null
[server] INFO: Retrying with -m800...
[server] ERROR: Encoding error: java.lang.IllegalStateException: null
2022-07-05 13:42:18.132 scrcpy[13923:6436890] WARN: Device disconnected
[server] ERROR: Exception on thread Thread[main,5,main]
java.lang.IllegalStateException
	at android.media.MediaCodec.native_dequeueOutputBuffer(Native Method)
	at android.media.MediaCodec.dequeueOutputBuffer(MediaCodec.java:3452)
	at com.genymobile.scrcpy.ScreenEncoder.encode(ScreenEncoder.java:152)
	at com.genymobile.scrcpy.ScreenEncoder.internalStreamScreen(ScreenEncoder.java:102)
	at com.genymobile.scrcpy.ScreenEncoder.streamScreen(ScreenEncoder.java:74)
	at com.genymobile.scrcpy.Server.scrcpy(Server.java:101)
	at com.genymobile.scrcpy.Server.main(Server.java:335)
	at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
	at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:399)

I've tried the cases that are described on this page https://github.com/Genymobile/scrcpy/blob/master/FAQ.md#exception

nikolai-ivanov avatar Jul 05 '22 20:07 nikolai-ivanov

Same problem for me. This is reproducible on every M1 Mac with a Pixel pro 6 emulator and API 29/28.

galinareznikk avatar Mar 06 '23 10:03 galinareznikk

This is an encoder issue on the device. Try with another encoder.

rom1v avatar Mar 06 '23 14:03 rom1v

Now I have this error, and it looks similar to this issue [server] INFO: Device: unknown Android SDK built for arm64 (Android 9) [server] ERROR: Encoding error: java.lang.IllegalArgumentException: null [server] INFO: Retrying with -m2560... [server] ERROR: Encoding error: java.lang.IllegalStateException: null [server] INFO: Retrying with -m1920... [server] ERROR: Encoding error: java.lang.IllegalStateException: null [server] INFO: Retrying with -m1600... 2023-03-08 17:28:52.796 scrcpy[1167:28135] INFO: Renderer: metal 2023-03-08 17:28:52.801 scrcpy[1167:28135] INFO: Initial texture: 1440x3120 2023-03-08 17:28:57.714 scrcpy[1167:28135] WARN: Device disconnected

galinareznikk avatar Mar 08 '23 16:03 galinareznikk

@rom1v change encoders don't help. Pls reproduce this

avd.ini.displayname              Nexus 5 API 29
avd.ini.encoding                 UTF-8
AvdId                            Nexus_5_API_29
disk.dataPartition.size          2G
fastboot.chosenSnapshotFile
fastboot.forceChosenSnapshotBoot no
fastboot.forceColdBoot           no
fastboot.forceFastBoot           yes
hw.accelerometer                 yes
hw.arc                           false
hw.audioInput                    yes
hw.battery                       yes
hw.camera.back                   virtualscene
hw.camera.front                  emulated
hw.cpu.ncore                     4
hw.device.hash2                  MD5:041eb4f348dec9fd18091e32004fae73
hw.device.manufacturer           Google
hw.device.name                   Nexus 5
hw.dPad                          no
hw.gps                           yes
hw.gpu.enabled                   yes
hw.gpu.mode                      auto
hw.initialOrientation            Portrait
hw.keyboard                      yes
hw.lcd.density                   480
hw.lcd.height                    1920
hw.lcd.width                     1080
hw.mainKeys                      no
hw.ramSize                       1536
hw.sdCard                        yes
hw.sensors.orientation           yes
hw.sensors.proximity             yes
hw.trackBall                     no
image.androidVersion.api         29
image.sysdir.1                   system-images/android-29/google_apis_playstore/arm64-v8a/
PlayStore.enabled                true
runtime.network.latency          none
runtime.network.speed            full
showDeviceFrame                  yes
skin.dynamic                     yes
tag.display                      Google Play
tag.id                           google_apis_playstore
vm.heapSize                      128

fleytman avatar Mar 24 '23 16:03 fleytman

Context: I'm trying to access AVD emulator from Mac on Windows through scrcpy by forwarding the ADB TCP port.

I've tried all three encoders listed as well:

PS D:\customBinaries\scrcpy-win64-v2.0> .\scrcpy.exe -s 127.0.0.1:5555 --list-encoders
scrcpy 2.0 <https://github.com/Genymobile/scrcpy>
D:\customBinaries\scrcpy-win64-v2.0\scrcpy-server: 1 file pushed, 0 skipped. 49.1 MB/s (52867 bytes in 0.001s)
[server] INFO: List of video encoders:
    --video-codec=h264 --video-encoder='c2.android.avc.encoder'
    --video-codec=h264 --video-encoder='OMX.google.h264.encoder'
    --video-codec=h265 --video-encoder='c2.android.hevc.encoder'
[server] INFO: List of audio encoders:
    --audio-codec=opus --audio-encoder='c2.android.opus.encoder'
    --audio-codec=aac --audio-encoder='c2.android.aac.encoder'
    --audio-codec=aac --audio-encoder='OMX.google.aac.encoder'

Having the same issue as above:

scrcpy 2.0 <https://github.com/Genymobile/scrcpy>                                                                                                                   [0/719]D:\customBinaries\scrcpy-win64-v2.0\scrcpy-server: 1 file pushed, 0 skipped. 136.8 MB/s (52867 bytes in 0.000s)
[server] INFO: Device: Google Android SDK built for arm64 (Android 10)
[server] WARN: Audio disabled: it is not supported before Android 11
[server] ERROR: Encoding error: java.lang.IllegalStateException: null
[server] INFO: newMaxSize = 1920
[server] INFO: Retrying with -m1920...
[server] INFO: Retrying...
[server] INFO: newMaxSize = 1600
[server] INFO: Retrying with -m1600...
[server] INFO: Retrying...
[server] ERROR: Encoding error: java.lang.IllegalStateException: null
[server] INFO: newMaxSize = 1280
[server] INFO: Retrying with -m1280...
[server] INFO: Retrying...
[server] ERROR: Encoding error: java.lang.IllegalStateException: null
[server] ERROR: Encoding error: java.lang.IllegalStateException: null
[server] INFO: newMaxSize = 1024
[server] INFO: Retrying with -m1024...
[server] INFO: Retrying...
[server] ERROR: Encoding error: java.lang.IllegalStateException: null
[server] INFO: newMaxSize = 800
[server] INFO: Retrying with -m800...
[server] INFO: Retrying...
INFO: Renderer: direct3d
WARN: Demuxer 'audio': stream explicitly disabled by the device
INFO: Initial texture: 1080x2336
[server] ERROR: Encoding error: java.lang.IllegalStateException: null
[server] INFO: newMaxSize = 0
WARN: Device disconnected
[server] ERROR: Exception on thread Thread[main,5,main]
java.lang.IllegalStateException
        at android.media.MediaCodec.native_dequeueOutputBuffer(Native Method)
        at android.media.MediaCodec.dequeueOutputBuffer(MediaCodec.java:2789)
        at com.genymobile.scrcpy.ScreenEncoder.encode(ScreenEncoder.java:169)
        at com.genymobile.scrcpy.ScreenEncoder.streamScreen(ScreenEncoder.java:95)
        at com.genymobile.scrcpy.Server.scrcpy(Server.java:133)
        at com.genymobile.scrcpy.Server.main(Server.java:381)
        at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
        at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:338)

Anon-Exploiter avatar Jul 04 '23 00:07 Anon-Exploiter