scrcpy icon indicating copy to clipboard operation
scrcpy copied to clipboard

Unable to use scrcpy with AMD graphics in Linux

Open heurekus opened this issue 2 years ago • 11 comments

Environment

  • OS: Ubuntu 20.04
  • scrcpy version: 1.18
  • installation method: snap
  • device model: S21
  • Android version: 11

Describe the bug

when launching scrcpy from bash I get the following error message. There are similar reports for other projects citing amdgpu.ids not accessible from snap packages due to Apparmor restrictions. Perhaps that's the same thing here. Note: I have a notebook with Ryzen 7 CPU 4750U with AMD GPU obviously:

x@x:~$ scrcpy

INFO: scrcpy 1.18 <https://github.com/Genymobile/scrcpy>
/usr/local/share/scrcpy/scrcpy-server: 1 file pushed. 1.2 MB/s (37330 bytes in 0.030s)
[server] INFO: Device: samsung SM-G998B (Android 11)
/usr/share/libdrm/amdgpu.ids: No such file or directory
si_init_perfcounters: max_sh_per_se = 2 not supported (inaccurate performance counters)
X Error:  BadAlloc
  Request Major code 149 ()
  Request Minor code 2
  Error Serial #109
  Current Serial #110

heurekus avatar Aug 27 '21 07:08 heurekus

Try a non-snap version.

rom1v avatar Aug 27 '21 08:08 rom1v

Would like to but can't do it on this machine. Unfortunately that's the only AMD Ryzen machine I have.

heurekus avatar Aug 27 '21 08:08 heurekus

Idea: I will boot from USB later and do it there. Will let you know.

heurekus avatar Aug 27 '21 08:08 heurekus

I tried the non-snap version on an Ubuntu 20.04 installation that did not have a scrcpy install so far on the notebook with AMD CPU/GPU.

I did the following:

  • did a 'snap install scrcpy' to see if it would work on that machine. Result: Same error as above
  • reboot + install via recommended quick procedure (git clone + install script): Result: scrcpy works. Uninstalled again.
  • reboot + another snap install to see if the direct install might have done something good: Same error again as above.

So it looks like the snap security profile does not allow access to the AMD GPU specific stuff or the snap package is missing it.

` #.#.#.#.#.# Output of native install on Ubuntu 20.04

x@x:~$ scrcpy INFO: scrcpy 1.18 https://github.com/Genymobile/scrcpy /usr/local/share/scrcpy/scrcpy-server:...shed. 2.6 MB/s (37330 bytes in 0.014s) [server] INFO: Device: samsung SM-G996B (Android 11) INFO: Renderer: opengl INFO: OpenGL version: 4.6 (Compatibility Profile) Mesa 21.0.3 INFO: Trilinear filtering enabled INFO: Initial texture: 1080x2400

--> everything is working --> uninstall and reboot afterwards with the provided script. Left packages installed with apt as they were.

#.#.#.#.#.# Output of scrcpy snap install + execution

x@x:$ snap install scrcpy scrcpy v1.18 from sisco311 installed martin@sidekick-m:~$ adb devices List of devices attached

  • daemon not running; starting now at tcp:5037
  • daemon started successfully

martin@sidekick-m:$ scrcpy INFO: scrcpy 1.18 https://github.com/Genymobile/scrcpy /usr/local/share/scrcpy/scrcpy-server: 1 file pushed. 1.8 MB/s (37330 bytes in 0.020s) [server] INFO: Device: samsung SM-G996B (Android 11) /usr/share/libdrm/amdgpu.ids: No such file or directory si_init_perfcounters: max_sh_per_se = 2 not supported (inaccurate performance counters) X Error: BadAlloc Request Major code 149 () Request Minor code 2 Error Serial #105 Current Serial #106 `

heurekus avatar Aug 28 '21 10:08 heurekus

any updates on this one?

heurekus avatar Sep 21 '21 07:09 heurekus

cc @sisco311

rom1v avatar Sep 21 '21 07:09 rom1v

Guys, the problem is the following:

/usr/share/libdrm/amdgpu.ids: No such file or directory

I had a look and the file is part of your snap distribution. However, the snap yaml file does not contain it in the libraries path so it is not available inside the snap container. Could you please have a look at the snap yaml file, put this path (XXXX/usr/share/libdrm) and then check whether amdgpu.ids is accessible inside the snap container? That should do the trick :)

You can check if it's mapped inside by logging into the snap container:

snap run --shell scrcpy

heurekus avatar Dec 06 '21 13:12 heurekus

@heurekus, thanks for the suggestion. Added a bind to libdrm.

Please install the snap from the edge channel and see if this solves the issue.

Thanks.

sisco311 avatar Dec 07 '21 10:12 sisco311

@sisco311 Wow, yes, it works again now! Cool, thanks!

heurekus avatar Dec 08 '21 06:12 heurekus

No problem.

Applied the fix to the versions from the beta and stable channel.

sisco311 avatar Dec 08 '21 08:12 sisco311

Currently using the stable channel doesn't still work, and throws up the same error. @sisco311 please look if the fix has been properly applied. The edge channel runs perfectly though. scrcpy version 1.24

shouryade avatar Jun 22 '22 12:06 shouryade

how can i downgrade snap ?? now 1.25 to 1.24 with amd same issue fedora 37

View-my-Git-Lab-krafi avatar Jan 13 '23 09:01 View-my-Git-Lab-krafi

Same issue here. Stable channel doesn't work but edge channel is working for me.

agentzhao avatar Jan 30 '23 07:01 agentzhao

Hey! Just gave this a try right now, and v1.25 from the stable channel unfortunately still does not have the fix. Then removed and installed v1.21 from the edge channel. This still works but unfortunately, as Android progresses, v1.21 becomes less and less useful. Would be great if the fix made it into the stable channel as well :)

heurekus avatar Nov 08 '23 18:11 heurekus

@heurekus Try uninstalling the snap version and installing the latest version manually: https://github.com/Genymobile/scrcpy/blob/master/doc/linux.md#latest-version

rom1v avatar Nov 08 '23 18:11 rom1v

Hi rom1v. Many thanks for the tip! I installed the latest version (v2.2) on Ubuntu 22.04 today (git clone, etc.) and this version is working fine with AMD CPUs. Great! I had no idea that the (unofficial) snap package 1.25 is sooooo far behind. Cheers! :)

heurekus avatar Nov 09 '23 08:11 heurekus