utmapp / UTM

Virtual machines for iOS and macOS
https://getutm.app
Apache License 2.0
26.49k stars 1.33k forks source link

NOTICE: Mesa after 22.1.7 is broken (black screen, crashing apps) #4983

Closed ktprograms closed 1 year ago

ktprograms commented 1 year ago

Thanks everyone who's reported this issue, I've found that it's because of a switch to NIR-to-TGSI between 22.1.7 and 22.2.0.

There's 2 mitigations currently, pick between 1 and 2 based on your priorities (if its keeping your distro configs, then choose 1, or if you need GPU acceleration, then choose 2):

  1. Change the Emulated Display Card to virtio-ramfb or any other card without a -gl suffix.
  2. Switch to a distro that ships mesa<=22.1.7, such as Debian 11 or Alpine 3.16

If anyone has knowledge on how this can be debugged or fixed, please don't hesitate to comment on this issue (or join the UTM Discord server if this issue has comments locked). Please note that I don't particularly need logs (I already have virglrenderer traces), but if you have logs that point to the problematic code, please share them :)

fabiensanglard commented 1 year ago

Is the issue really with Mesa's TGSI or is it a problem with virtio implementation replying on unspecified behavior of Mesa NIR? ?

In other words: Should we report this issue to Mesa (can they fix it on their end)? Or should we report this issue to whoever maintains virtio implementation?

tvolin commented 1 year ago

I don't consider #4982 a dupe of this bug. As per my comment on that issue, I suggest you change the defaults or add something to the doc page for installing Fedora. This Mesa issue reports the upstream cause, but the symptom is easy for UTM itself to address

osy commented 1 year ago

I opened an issue with mesa and hopefully we can get some help root causing it: https://gitlab.freedesktop.org/mesa/mesa/-/issues/8382

In the meantime, we will revert the change in 4.1 so by default GPU acceleration is disabled again.

archanox commented 1 year ago

I followed option 3 as stated above, and ran glxgears which got me the following appear in the console

Mesa: warning: failed to remap glDrawRangeElementsBaseVertex
Mesa: warning: failed to remap glMultiDrawElementsBaseVertex
Mesa: warning: failed to remap glDrawArraysInstancedBaseInstance
Mesa: warning: failed to remap glDrawElementsInstancedBaseVertexBaseInstance
Mesa: warning: failed to remap glGetObjectLabelEXT
Mesa: warning: failed to remap glLabelObjectEXT
Mesa: warning: failed to remap glDrawArraysUserBuf
Mesa: warning: failed to remap glDrawElementsUserBuf
Mesa: warning: failed to remap glMultiDrawArraysUserBuf
Mesa: warning: failed to remap glMultiDrawElementsUserBuf
Mesa: warning: failed to remap glDrawArraysInstancedBaseInstanceDrawID
Mesa: warning: failed to remap glDrawElementsInstancedBaseVertexBaseInstanceDrawID

And I still have a black window.

ktprograms commented 1 year ago

Weird. Sorry, but I don't have time to debug why the patch doesn't work for some people, as well as trying to help figure out the bug itself, so I'll be removing the patch instructions.

If you're okay with using Debian, Debian 11 still uses an old enough mesa that the issue doesn't affect it. Alpine 3.16 would also work (and so would any distro that ships mesa<=22.1.7)

KimonHoffmann commented 1 year ago

I can second that applying the patch above did not fix the problem for me either. I have tested it against Mesa 22.3.2 as well as Mesa 22.3.5. If there is more information I can supply to help the search for the root cause along, please give me a shout.

zuzzurro commented 1 year ago

Fedora 38 beta (just upgraded) runs again fine with acceleration enabled (using virtio-gpu-gl-pci). Here's a screenshot:

Screenshot 2023-03-06 at 20 39 45

Please note the broken (not round) right-top and left-bottom corners of the settings window. I think I've had them like this since I started using accelerated drivers. Did anyone else notice the same issue?

thedustinmiller commented 1 year ago

I can confirm partial improvements with Fedora 38. More things work, like firefox is able to render basic pages, however anything requiring opengl or vulkan acceleration is still failing. This is using both metal and opengl backends and both KDE and GNOME.

Notably, Fedora 38 is using mesa 23.0.0.

tifasoftware commented 1 year ago

I am observing the same corner glitch in Ubuntu 22.10. Im using ANGLE (Metal)

driversti commented 1 year ago

Hi all. I'm not sure if my issue is related to the one mentioned here, but I cannot boot into my VM. This is what I'm seeing now: image From yesterday, I had 3 identical VM running (Debian 11 (LXDE)). But a few hours ago UTM unexpectedly closed. After that one VM doesn't boot. I had the same about 2-3 days ago. Configuring my VM takes some time and is quite annoying, so this situation doesn't make me happy. What can cause this issue? How can I avoid it? Setting up 3 VMs every a few days will make me crazy :D

tifasoftware commented 1 year ago

What is your emulated display device?

driversti commented 1 year ago

Thank you for the replay, @tifasoftware. I use the default one for a downloaded image - virtio-ramfb

tifasoftware commented 1 year ago

Thank you for the replay, @tifasoftware. I use the default one for a downloaded image - virtio-ramfb

This issue concerns cards with 3D acceleration that include -gl in its name. Your card is not 3D accelerated and is unaffected by this issue.

driversti commented 1 year ago

Okay, thanks. @tifasoftware Do you know if there is already an issue related to my problem?

tifasoftware commented 1 year ago

Okay, thanks. @tifasoftware Do you know if there is already an issue related to my problem?

I recommend opening a new issue

driversti commented 1 year ago

Okay, thanks. @tifasoftware Do you know if there is already an issue related to my problem?

I recommend opening a new issue

Thank you :)

csmaxx commented 1 year ago

I'm running Ubuntu 22.04 and it renders GDM and the gnome desktop just fine with one of the gl devices. I tried to install lightdm, qtile and xmonad tiling window managers. but none if that renders it shows a black screen. The ui is there the mouse cursor changes to an I-beam cursor when hovering over text fields.

So it seems that the gl devices only works with GDM and gnome desktop.

farovitus commented 1 year ago

I'm running Ubuntu 22.04 and it renders GDM and the gnome desktop just fine with one of the gl devices. I tried to install lightdm, qtile and xmonad tiling window managers. but none if that renders it shows a black screen. The ui is there the mouse cursor changes to an I-beam cursor when hovering over text fields.

So it seems that the gl devices only works with GDM and gnome desktop.

i am trying to install Ubuntu 22.04.2 LTS (Jammy Jellyfish) Daily Build on mac m1 and it doesn't open installation windows or any app in the live version, i only get black windows when using -gl

DragonSWDev commented 1 year ago

Isn't it possible to disable NIR-to-TGSI with some environmental variable? I've found that there is environmental variable called "VIRGL_DEBUG" where you can set it to "use_tgsi" and that should force Mesa to use TGSI directly but it didn't help, still some applications (like Firefox or glxgears) can't render properly.

EvanCarroll commented 1 year ago

This is such a major issue, not having hardware accl on apple silicon in a VM really sucks. I hate OSX so I basically use a VM to host a Linux desktop running i3. Because I lack hardware acceleration, I can't run Slack and Zoom in the VM. Because of that, I can't give the VM the sound card because I need it for Slack and Zoom. So my VM has no sound.

Can we bug bounty this? This M1 mac is a total nightmare.

osy commented 1 year ago

It’s a Mesa driver bug and we need either help from them or someone to test and send feedback to them.

osy commented 1 year ago

@akihikodaki Curious if you ran into similar issues with Mesa in your QEMU fork?

akihikodaki commented 1 year ago

@osy It's not Mesa bug but ANGLE one. (Well, TGSI-to-NIR change is so big that actually there can be other bugs, but the major issue is in ANGLE.) The bug is fixed with: https://chromium-review.googlesource.com/c/angle/angle/+/3996520

So updating ANGLE should fix it.

osy commented 1 year ago

Thanks @akihikodaki it seems like updating ANGLE fixes the black window issue when launching X11 apps. It seems that there are still Wayland issues (Firefox crashing on launch for example) but can be mitigated by logging in with Ubuntu on Xorg or Debian on Xorg option. The latest ANGLE also seems to introduce more issue in the Metal backend because it no longer is able to fully render the login screen (the prompt and buttons don't appear).

archanox commented 1 year ago

Can the ANGLE issues be mitigated by migrating to Zink + MoltenVk?

osy commented 1 year ago

@archanox As far as I’m aware, Zink isn’t available for macOS. The closest thing to ANGLE is MoltenGL which is a commercial product.

akihikodaki commented 1 year ago

@osy I guess that problem is fixed with: https://gitlab.freedesktop.org/mesa/mesa/-/commit/36d050210ea854f2632c8c2a960dca94dabbf526

Metal backend is marked ready in the latest main branch but not in stable release. OpenGL backend is still the default and Chromium also doesn't use it. You cannot still use Metal backend.

Use latest stable ANGLE and Mesa with my patched virglrenderer and QEMU. Expect any kind of failures if you use something outdated.

osy commented 1 year ago

I've done a bad thing and built the latest Mesa git commit masquerading as 22.2.5 (because I didn't want to mess with dependencies). If you are running ARM64 Ubuntu 22.04.1 (and ONLY that version), you can install these replacement DEBs to get Wayland apps like Firefox to work.

mesa-a18a51a708a86f51e0a5ab031b379f65bc84fb49.tgz

Andy312432 commented 1 year ago

The latest commit in virglrenderer seems to adjust something about tgsi… Maybe update sync the commit again?

osy commented 1 year ago

@Andy312432 who are you replying to? I just built commit a18a51a708a86f51e0a5ab031b379f65bc84fb49 and also I said it was working so I'm not understanding your comment

Andy312432 commented 1 year ago

Oh I thought wayland wayland problem still persist and we haven't update that... Sorry!!

Andy312432 commented 1 year ago

@osy Sorry that maybe I didn't express it well, but I think maybe we can update the virglrenderer to the latest commit so that maybe it will fix something?

And a little bit off topic, since angle seems to have opengles 3.0 ready, can we have opengl 3 in our VM?

osy commented 1 year ago

@Andy312432 as we’ve discussed above, the issue isn’t with virglrenderer PLUS it’s already updated to the latest (well it’s a few weeks old now but it’s long after this ticket was opened). Please keep up with the conversation.

ANGLE does not have full 3.0 support for Apple systems.

gasinvein commented 1 year ago

This seems to be fixed in 4.2.4. Tested with Fedora 38, GNOME Wayland session, booted with initcall_blacklist=sysfb_init; used glmark2 and glmark2-wayland programs. Oddly enough and contrary to the known issues list, it seems to work fine with the Metal ANGLE backend as well.

EvanCarroll commented 1 year ago

Just wanted to confirm the fix. I'm using an unmodified version of Debian testing and things work with OpenGL virtio-ramfb-gl Kudos.

DragonSWDev commented 1 year ago

I also can confirm fix. On UTM version 4.2.5 3D acceleration with GPU set to virtio-gpu-gl-pci works as expected on Fedora 38 guest. I'm using GNOME Wayland session and both Wayland and X11 applications are working without issues. I have ANGLE set to use OpenGL backend, I haven't tried Metal backend yet.

archanox commented 1 year ago

UTM is still on 4.1.6 in the Appstore, is there an issue with deployment there?

thedustinmiller commented 1 year ago

4.2.5 on MacBook air M2 has 3d acceleration working with my Arch install with KDE Plasma, both Wayland and X11.

EvanCarroll commented 1 year ago

UTM is still on 4.1.6 in the Appstore, is there an issue with deployment there?

New version in brew. Why let Apple do what the open source community does better.

osy commented 1 year ago

I will close the issue since it seems like the main issues are resolved and we’re veering off topic. If any new graphics issues arise, we can open a new one.

archanox commented 1 year ago

New version in brew. Why let Apple do what the open source community does better.

Because the appstore auto updates, I can support the project financially, and the app store is fine, it's just updates aren't getting pushed out by the project for whatever reason.

osy commented 1 year ago

for whatever reason

Reason being that it’s been 24 hours (v4.2.4 was approved but I pulled it last second due to the Monterey mouse cursor problem).

archanox commented 1 year ago

As far as I’m aware, Zink isn’t available for macOS.

Did a quick google and found this https://www.phoronix.com/news/Mesa-22.0-Build-macOS-Zink

osy commented 1 year ago

Yeah I know about the super experimental stuff. If you really believe the thing that nobody has used in production would work better than the thing Google is actively developing and distributing as part of Chrome, then please put in the effort to get it working and open a pull request and I’ll review it 🙂

trevorstr commented 11 months ago

I had the same problem: black screen upon installing Ubuntu Desktop 22.04 LTS Jammy Jellyfish on UTM 4.3.5.

Environment

Workaround

I changed the display adapter to virtio-ramfb, and it works alright. I can see the Ubuntu login screen and desktop now.

I wonder if there's a better user experience than requiring a Google search to use Ubuntu Desktop? If someone tries installing Ubuntu Desktop, should they be prompted to use a different display adapter?

osy commented 11 months ago

There is no way for UTM to know that Mesa upstream went and broke some feature. By the way you're on the wrong issue, this is very old, you're looking at the new Mesa-breaking-all-vms issue here #5749

juicejuice commented 1 month ago

Just to note that whatever this is still seems to be occurring in August 2024. Yesterday, I downloaded UTM and pre-packaged Ubuntu 22.04. When I started the VM it went black so I googled and found this issue. The solution, of course, is to switch display adapter to virtio-ramfb.