scrcpy: [server] ERROR: Encoding error: java.lang.IllegalStateException: null WARN: Device disconnected

  • I have read the FAQ.
  • I have searched in existing issues.

Environment

  • OS: Windows 11
  • scrcpy version: 1.23
  • installation method: windows release
  • device model: Redmi Note 10 Pro
  • Android version: 12
scrcpy 1.23 <https://github.com/Genymobile/scrcpy>
C:\Users\Admin\Downloads\scrcpy-win64\scrcpy-ser...ed, 0 skipped. 16.1 MB/s (41123 bytes in 0.002s)
[server] INFO: Device: Xiaomi M2101K6G (Android 12)
INFO: Renderer: direct3d
INFO: Initial texture: 1080x2400
[server] ERROR: Encoding error: java.lang.IllegalStateException: null
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(Unknown Source:9)
        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:331)
        at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
        at com.android.internal.os.RuntimeInit.main(Unknown Source:24)
Press any key to continue . . .

that’s all i got 2 device Redmi note 4x (it’s work perfectly) Redmi note 10 Pro (as the error above)

EDIT by @rom1v: It looks like a bug in MIUI 13. You’ll have to wait until Xiaomi fixes the issue. EDIT2: to fix the problem, upgrade to MIUI 13.0.12.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 140

Most upvoted comments

I’m having the same issues in Redmi Note 10 Pro after updating to MIUI 13 and Android 12, any fixes found?

EDIT: changing the encoder works: --encoder ‘OMX.google.h264.encoder’ EDIT2: you can control the phone but it freezes on PC screen.

Hi guys, there is an update on this. I have just got a security update on my Xiaomi Note 10 Pro and scrcpy started working! MIUI 13 Global 13.0.12.0 Stable.

This is so sad all redmi note 10 pro after updates it makes scrcpy stop functioning, hope a solution soon.

Also using Xiaomi redmi note 10 pro and scrcpy is not working now. i also have issues on its camera even before the update. annoying

oh god could anybody fix this issue, this sucks man!

scrcpy --encoder ‘OMX.qcom.video.encoder.avc’

Result: crash

scrcpy --encoder ‘c2.android.avc.encoder’ scrcpy --encoder ‘OMX.google.h264.encoder’

Result: starts, but freezes screen (no update or refresh)

Hope the author finds a fix.

I have currently no device with this ROM to reproduce, but I think the fix is to wait for Xiaomi to fix the bug in the latest version of their custom rom. 😕

As I said in another comment, this is happening to me right now on my Xiaomi Mi A1 but not with MUI. I’m using LineageOS 18.1 (android 11) on this device. Before, on the same device, but with LineageOS 16.1 (android 9), it was working fine.

I don’t know if, and how, this information would help tho

Ok, I don’t know if I’m doing it well with github (not used on commenting here), but I’m managed to make it work.

I notice that, when using another encoder, scrcpy would just stop executing itself without any error :

scrcpy --encoder OMX.qcom.video.encoder.avc

Gave me this :

scrcpy 1.23 <https://github.com/Genymobile/scrcpy> C:\XXX\scrcpy-win64-v1.... file pushed, 0 skipped. 51.4 MB/s (41123 bytes in 0.001s) [server] INFO: Device: Xiaomi Mi A1 (Android 11) INFO: Renderer: direct3d INFO: Initial texture: 1080x1920

But nothing else.

But if I run scrcpy again (without any command parameter, just clicking scrcpy.exe) while the other instance is running, it works perfectly fine ! I have no idea why, but maybe that could help someone here.

scrcpy --encoder ‘OMX.qcom.video.encoder.avc’

Result: crash

scrcpy --encoder ‘c2.android.avc.encoder’ scrcpy --encoder ‘OMX.google.h264.encoder’

Result: starts, but freezes screen (no update or refresh)

Exact same problem 😦

(I love you rom1v 🧡💚💙)

How to push update on Global rom 13.0.9 to update 13.0.12

does anyone have a workaround for this? … it’s been a while since we received an update from Xiaomi.

This applies to all Xiaomi/Redmi devices affected

Check xiaomifirmwareupdater.com for official updates, if any. Sometimes the MIUI updater just doesn’t push them to you.

If there is no official update and you are comfortable tinkering with the device, an alternative would be to use custom ROMs, especially Xiaomi.eu ROM if you like how MIUI does things and want a stable experience for the device. For an actual guide on how to do so, I would have to ask you to google it.

PS: Xiaomi.eu doesn’t have a ROM build for sweetin devices, i.e. Redmi Note 10 Pro Max India. However, the build for sweet devices, i.e. Redmi Note 10 Pro Global works fine with it. For other Xiaomi devices, one might have to test several ROMs before finding the right one.

@iMaiconP @daydy225

manoaratefy

Unfortunately RN10 Pro Max India has not receive the update the lastest update is 13.0.5.0 😕

scrcpy --encoder 'c2.android.avc.encoder'
scrcpy --encoder 'OMX.google.h264.encoder'

Open the screen, but the screen doesn’t update after the first frame. However, the phone remains controllable.

scrcpy --encoder 'OMX.qcom.video.encoder.avc' Directly leads to crash

I’m on Android 12, MIUI 13

it is weird that I didn’t have this problem until I reinstall my ubuntu. Same hardware and same phone. Just ubuntu reinstalled. I don’t know what I installed in the previous ubuntu.

You probably get an upgrade on the phone. The error occurs on the device, and the client operating system has no impact on it.

There is NO need to complain here. Everybody with this problem, should send e-mail directly to Xiaomi.

Is THEIR responsibility to fix it.

It seems like MIUI 13 has an issue with the scrcpy’s default encoder OMX.qcom.video.encoder.avc.

scrcpy not crash with other two encoders, they are -

  • scrcpy --encoder 'OMX.google.h264.encoder'
  • scrcpy --encoder 'c2.android.avc.encoder'

With those, you can control the device but it will freeze on the first frame.

But with default encoder scrcpy --encoder 'OMX.qcom.video.encoder.avc', java server throw error Encoding error: java.lang.IllegalStateException: null and crash with the same java exception

[server] ERROR: Encoding error: java.lang.IllegalStateException: null
2022-05-09 10:34:39.879 scrcpy[29316:119119] 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:3535)
	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:363)

It seems a lot of people are having issues with the encoder lately and can’t use scrcpy anymore. Hope the author finds a fix.

Xiaomi is rolling out update that fixed the issue. I got september patch install recently 13.0.10 and yep no more crash like before. That’s crazy cool!

E3004: This package is for “sweet” devices; this is a “sweetin”.

you need to edit the updater-script inside the zip package. instructions can be found on the internet. @iMaiconP

please do not hijack the comment section here, GH sends out a ping to everyone for every comment. dm me on Twitter/Insta (see my website/profile for handles) if necessary.

Hi guys, there is an update on this. I have just got a security update on my Xiaomi Note 10 Pro and scrcpy started working! MIUI 13 Global 13.0.12.0 Stable.

Indeed! Xiaomi.eu 13.0.12 for sweet and sweetin devices fixes the bug as well. @dmytromarchuk

What would be the right action for the GH issue here @rom1v? The bug clearly resided on Xiaomi’s side and is being fixed with OTA updates. Should the issue be closed?

Please how to get 13.0.12 update on glabal rom, i’ve been dead waiting for update.

People with xiaomi redmi 10 on Global Rom make us know if you fixed the issue.

I can confirm that on Xiaomi Note 10 Pro with MIUI-V13.0.13.0.SKFEUXM it works.

yes, plz help, I’m stuck in this ~ and I’m sweeping the internet for this issue and looking this issue(github) since feb

I’m using note 10 pro, and it just do not work!

Try this

scrcpy --encoder 'OMX.google.h264.encoder'

It works for me

I just did it and it worked. I’m very grateful for that. Many blessings to you

Having the same issue with a modern Samsung device here, so yeah, probably not something unique to Xiaomi.

There is NO need to complain here. Everybody with this problem, should send e-mail directly to Xiaomi.

Is THEIR responsibility to fix it.

Sorry, but I am not complaining about it. and my phone is a Huawei device and never upgrade years ago. maybe there is something wrong with my ubuntu environment. I am still working on it.

it is weird that I didn’t have this problem until I reinstall my ubuntu. Same hardware and same phone. Just ubuntu reinstalled. I don’t know what I installed in the previous ubuntu.

Estou com o mesmo problema no redmi note 10 pro. Tanto no scrcpy como nos outros apps de controle. Espero que o autor resolva

man oh man i guess there is no hope for xiaomi devices , suck i should have not updated the phone…

I’m also facing similar issues as @Gradius2 has reported.

Is this fixed finally? I have a Miui 12.5 phone which is asking me to update to Miui 13 with Android 12 but I’m holding it because this issue with scrcpy because I use it a lot.

Can confirm this issue isn’t fixed as of today. Do not update.

Hope the author finds a fix.

I have currently no device with this ROM to reproduce, but I think the fix is to wait for Xiaomi to fix the bug in the latest version of their custom rom. 😕

What’s sad about this is it’s gonna take months before this gets fixed for RN10/Xiaomi users haha. Understandable on your side tho. Thanks for the efforts!

Does it work with screenrecord:

adb shell screenrecord /sdcard/file.mp4
adb pull /sdcard/file.mp4

?

EDIT: fixed.

C:\Users\Admin\Downloads\scrcpy-win32-v1.23>scrcpy -d -m1024
scrcpy 1.23 <https://github.com/Genymobile/scrcpy>
C:\Users\Admin\Downloads\scrcpy-win32-v1.23\scrc...ed, 0 skipped. 25.3 MB/s (61061 bytes in 0.002s)
[server] INFO: Device: Xiaomi M2101K6G (Android 12)
[server] INFO: FIRST FRAME SENT
INFO: Renderer: direct3d
INFO: Initial texture: 464x1024
[server] ERROR: Encoding error: java.lang.IllegalStateException: null
[server] INFO: downsizeOnError=true; firstFrameSent=true
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(Unknown Source:9)
        at com.genymobile.scrcpy.ScreenEncoder.encode(ScreenEncoder.java:153)
        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:331)
        at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
        at com.android.internal.os.RuntimeInit.main(Unknown Source:24)``

still same got error lol… i tried to change encoder to

    --encoder 'c2.android.avc.encoder'
    --encoder 'OMX.google.h264.encoder' 

but it’s freeze frame