Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

egui/eframe using wgpu/GL panics at startup after upgrade to v0.22 #3068

Closed
NoisyCoil opened this issue Jun 10, 2023 · 8 comments
Closed

egui/eframe using wgpu/GL panics at startup after upgrade to v0.22 #3068

NoisyCoil opened this issue Jun 10, 2023 · 8 comments
Labels
bug Something is broken

Comments

@NoisyCoil
Copy link

NoisyCoil commented Jun 10, 2023

Describe the bug
On an Nvidia graphics card (NVIDIA Corporation GK107M [GeForce GT 750M Mac Edition]), every egui/eframe app panics at startup with an 'Error in Surface::configure: Validation Error, caused by Requested usage is not supported, when using wgpu. This didn't happen before the upgrade to v0.22.

To Reproduce
Steps to reproduce the behavior:

  1. Enable the "wgpu" feature in eframe
  2. Add Renderer::Wgpu to eframe's NativeOptions
  3. Compile

Expected behavior
The application should not panic.

Screenshots

Desktop (please complete the following information):

  • OS: Ubuntu 23.04 x86_64 (both Wayland and X11)
  • Version 0.22 and current master

Additional context
The error and backtrace I see e.g. with the hello_world example on Wayland is

   Compiling hello_world v0.1.0 (/home/user/egui/examples/hello_world)
    Finished dev [unoptimized + debuginfo] target(s) in 12.07s
     Running `/home/user/egui/target/debug/hello_world`
thread 'main' panicked at 'Error in Surface::configure: Validation Error

Caused by:
    Requested usage is not supported
', /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.16.0/src/backend/direct.rs:734:18
stack backtrace:
   0: rust_begin_unwind
             at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/core/src/panicking.rs:142:14
   2: wgpu::backend::direct::Context::handle_error_fatal
             at /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.16.0/src/backend/direct.rs:308:9
   3: <wgpu::backend::direct::Context as wgpu::context::Context>::surface_configure
             at /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.16.0/src/backend/direct.rs:734:13
   4: <T as wgpu::context::DynContext>::surface_configure
             at /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.16.0/src/context.rs:2056:9
   5: wgpu::Surface::configure
             at /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.16.0/src/lib.rs:4149:9
   6: egui_wgpu::winit::Painter::configure_surface
             at /home/user/egui/crates/egui-wgpu/src/winit.rs:139:9
   7: egui_wgpu::winit::Painter::resize_and_generate_depth_texture_view_and_msaa_view
             at /home/user/egui/crates/egui-wgpu/src/winit.rs:259:9
   8: egui_wgpu::winit::Painter::set_window::{{closure}}
             at /home/user/egui/crates/egui-wgpu/src/winit.rs:228:17
   9: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/core/src/future/mod.rs:91:19
  10: pollster::block_on
             at /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/pollster-0.3.0/src/lib.rs:128:15
  11: eframe::native::run::wgpu_integration::WgpuWinitApp::init_run_state
             at /home/user/egui/crates/eframe/src/native/run.rs:1167:13
  12: <eframe::native::run::wgpu_integration::WgpuWinitApp as eframe::native::run::WinitApp>::on_event
             at /home/user/egui/crates/eframe/src/native/run.rs:1376:25
  13: eframe::native::run::run_and_return::{{closure}}
             at /home/user/egui/crates/eframe/src/native/run.rs:181:28
  14: winit::platform_impl::platform::wayland::event_loop::EventLoop<T>::run_return
             at /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.6/src/platform_impl/linux/wayland/event_loop/mod.rs:242:9
  15: winit::platform_impl::platform::EventLoop<T>::run_return
             at /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.6/src/platform_impl/linux/mod.rs:785:56
  16: <winit::event_loop::EventLoop<T> as winit::platform::run_return::EventLoopExtRunReturn>::run_return
             at /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.6/src/platform/run_return.rs:51:9
  17: eframe::native::run::run_and_return
             at /home/user/egui/crates/eframe/src/native/run.rs:132:5
  18: eframe::native::run::wgpu_integration::run_wgpu::{{closure}}
             at /home/user/egui/crates/eframe/src/native/run.rs:1484:17
  19: eframe::native::run::with_event_loop::{{closure}}
             at /home/user/egui/crates/eframe/src/native/run.rs:116:9
  20: std::thread::local::LocalKey<T>::try_with
             at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/thread/local.rs:445:16
  21: std::thread::local::LocalKey<T>::with
             at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/thread/local.rs:421:9
  22: eframe::native::run::with_event_loop
             at /home/user/egui/crates/eframe/src/native/run.rs:109:5
  23: eframe::native::run::wgpu_integration::run_wgpu
             at /home/user/egui/crates/eframe/src/native/run.rs:1481:13
  24: eframe::run_native
             at /home/user/egui/crates/eframe/src/lib.rs:226:13
  25: hello_world::main
             at ./src/main.rs:12:5
  26: core::ops::function::FnOnce::call_once
             at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/core/src/ops/function.rs:248:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

The details of the graphics card via lspci -vv:

01:00.0 VGA compatible controller: NVIDIA Corporation GK107M [GeForce GT 750M Mac Edition] (rev a1) (prog-if 00 [VGA controller])
	Subsystem: Apple Inc. GK107M [GeForce GT 750M Mac Edition]
	Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
	Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 0, Cache Line Size: 256 bytes
	Interrupt: pin A routed to IRQ 54
	Region 0: Memory at b0000000 (32-bit, non-prefetchable) [size=16M]
	Region 1: Memory at 90000000 (64-bit, prefetchable) [size=256M]
	Region 3: Memory at a0000000 (64-bit, prefetchable) [size=32M]
	Region 5: I/O ports at 1000 [size=128]
	Expansion ROM at b1000000 [disabled] [size=512K]
	Capabilities: [60] Power Management version 3
		Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0-,D1-,D2-,D3hot-,D3cold-)
		Status: D0 NoSoftRst+ PME-Enable- DSel=0 DScale=0 PME-
	Capabilities: [68] MSI: Enable+ Count=1/1 Maskable- 64bit+
		Address: 00000000fee005f8  Data: 0000
	Capabilities: [78] Express (v2) Endpoint, MSI 00
		DevCap:	MaxPayload 256 bytes, PhantFunc 0, Latency L0s unlimited, L1 <64us
			ExtTag+ AttnBtn- AttnInd- PwrInd- RBE+ FLReset- SlotPowerLimit 75W
		DevCtl:	CorrErr+ NonFatalErr+ FatalErr+ UnsupReq+
			RlxdOrd+ ExtTag+ PhantFunc- AuxPwr- NoSnoop+
			MaxPayload 256 bytes, MaxReadReq 512 bytes
		DevSta:	CorrErr- NonFatalErr- FatalErr- UnsupReq- AuxPwr- TransPend-
		LnkCap:	Port #0, Speed 8GT/s, Width x16, ASPM L0s L1, Exit Latency L0s <512ns, L1 <4us
			ClockPM+ Surprise- LLActRep- BwNot- ASPMOptComp+
		LnkCtl:	ASPM L0s L1 Enabled; RCB 64 bytes, Disabled- CommClk+
			ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
		LnkSta:	Speed 2.5GT/s (downgraded), Width x16
			TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-
		DevCap2: Completion Timeout: Range AB, TimeoutDis+ NROPrPrP- LTR-
			 10BitTagComp- 10BitTagReq- OBFF Not Supported, ExtFmt- EETLPPrefix-
			 EmergencyPowerReduction Not Supported, EmergencyPowerReductionInit-
			 FRS- TPHComp- ExtTPHComp-
			 AtomicOpsCap: 32bit- 64bit- 128bitCAS-
		DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis- LTR- 10BitTagReq- OBFF Disabled,
			 AtomicOpsCtl: ReqEn-
		LnkCap2: Supported Link Speeds: 2.5-8GT/s, Crosslink- Retimer- 2Retimers- DRS-
		LnkCtl2: Target Link Speed: 8GT/s, EnterCompliance- SpeedDis-
			 Transmit Margin: Normal Operating Range, EnterModifiedCompliance- ComplianceSOS-
			 Compliance Preset/De-emphasis: -6dB de-emphasis, 0dB preshoot
		LnkSta2: Current De-emphasis Level: -3.5dB, EqualizationComplete+ EqualizationPhase1+
			 EqualizationPhase2+ EqualizationPhase3+ LinkEqualizationRequest+
			 Retimer- 2Retimers- CrosslinkRes: unsupported
	Capabilities: [b4] Vendor Specific Information: Len=14 <?>
	Capabilities: [100 v1] Virtual Channel
		Caps:	LPEVC=0 RefClk=100ns PATEntryBits=1
		Arb:	Fixed- WRR32- WRR64- WRR128-
		Ctrl:	ArbSelect=Fixed
		Status:	InProgress-
		VC0:	Caps:	PATOffset=00 MaxTimeSlots=1 RejSnoopTrans-
			Arb:	Fixed- WRR32- WRR64- WRR128- TWRR128- WRR256-
			Ctrl:	Enable+ ID=0 ArbSelect=Fixed TC/VC=ff
			Status:	NegoPending- InProgress-
	Capabilities: [128 v1] Power Budgeting <?>
	Capabilities: [420 v2] Advanced Error Reporting
		UESta:	DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
		UEMsk:	DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
		UESvrt:	DLP+ SDES+ TLP- FCP+ CmpltTO- CmpltAbrt- UnxCmplt- RxOF+ MalfTLP+ ECRC- UnsupReq- ACSViol-
		CESta:	RxErr- BadTLP- BadDLLP- Rollover- Timeout- AdvNonFatalErr+
		CEMsk:	RxErr- BadTLP- BadDLLP- Rollover- Timeout- AdvNonFatalErr+
		AERCap:	First Error Pointer: 00, ECRCGenCap- ECRCGenEn- ECRCChkCap- ECRCChkEn-
			MultHdrRecCap- MultHdrRecEn- TLPPfxPres- HdrLogCap-
		HeaderLog: 00000000 00000000 00000000 00000000
	Capabilities: [600 v1] Vendor Specific Information: ID=0001 Rev=1 Len=024 <?>
	Capabilities: [900 v1] Secondary PCI Express
		LnkCtl3: LnkEquIntrruptEn- PerformEqu-
		LaneErrStat: 0
	Kernel driver in use: nouveau
	Kernel modules: nvidiafb, nouveau

In case you are wondering, yes, I'm running Ubuntu on Apple hardware (Intel, no VMs). I understand this is not a common hardware/software combination, but then, again, everything used to work (and still does) up until v0.22. Enabling the "wayland" feature in eframe does not help, nor does it help switching to X11.

I tend to believe this is not an upstream bug, as the wgpu examples run seamlessly on the same graphics card. I am willing to provide any other useful information.

@NoisyCoil NoisyCoil added the bug Something is broken label Jun 10, 2023
@NoisyCoil NoisyCoil changed the title egui/eframe using wgpu panics at startup on Nvidia after upgrade to v0.22 egui/eframe using wgpu/GL panics at startup on Nvidia after upgrade to v0.22 Jun 11, 2023
@NoisyCoil
Copy link
Author

Update: I figured out that the issue is specifically with the GL backend of wgpu. Indeed, setting

options.wgpu_options.supported_backends = eframe::wgpu::Backends::GL;

results in the observed behavior, whereas setting

options.wgpu_options.supported_backends = eframe::wgpu::Backends::VULKAN;

does not (options of course are the NativeOptions): the application does not panic when using the Vulkan backend.

On the current main branch of wgpu, running

$ WGPU_BACKEND=gl cargo run --example cube

confirms that we're running on the GL backend,

Using NVE7 (Gl)

and shows the cube without panicking, so again I don't believe that the problem is upstream.

@NoisyCoil
Copy link
Author

I traced back this issue to commit 870264b, specifically to the line

usage: wgpu::TextureUsages::RENDER_ATTACHMENT | wgpu::TextureUsages::COPY_DST,

If I revert the change and remove wgpu::TextureUsages::COPY_DST, the GL backend works again.

@NoisyCoil NoisyCoil changed the title egui/eframe using wgpu/GL panics at startup on Nvidia after upgrade to v0.22 egui/eframe using wgpu/GL panics at startup after upgrade to v0.22 Jun 14, 2023
@NoisyCoil
Copy link
Author

It turns out that this issue does not depend on the Nvidia graphics card: I'm not able to run egui apps with wgpu on the GL backend also on a Debian 12 and on a Fedora 38 VM (on a host with an AMD GPU). Previously I thought it worked on them, but I just realized that wgpu had automatically selected Vulkan as its backend there. Using WGPU_BACKEND=gl shows the same behavior, namely it panics with

thread 'main' panicked at 'Error in Surface::configure: Validation Error

Caused by:
    Requested usage is not supported
', /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.16.0/src/backend/direct.rs:734:18

At this point, this issue has been reported by other applications that use egui (fralonra/wgshadertoy#3). Is anybody able to run egui 0.22 with wgpu on the GL backend? Could the original authors of the commit (@emilk and @amfaber) comment on how we can make the GL backend work again with the wgpu::TextureUsages::COPY_DST usage on? Thank you.

@amfaber
Copy link
Contributor

amfaber commented Jun 14, 2023

Thanks for bring this to my attention, great detective work!
I pulled together some quick triage on #3078, which effectively just disables the screenshot feature if running on the GL backend. The usage flag is unfortunately essential to the current implementation, and so for now I log an error and return None instead of a screenshot if one is requested while running the GL backend.
I tagged @Wumpf here and on the PR to hopefully pull in some more wgpu expertise.

@NoisyCoil
Copy link
Author

Tested the PR, seems to work now (as far as the panic is concerned)! Thank you for the quick reply!

@NoisyCoil
Copy link
Author

However, nevermind about fralonra/wgshadertoy#3: I had a look at their code and while they're using egui, it looks like they're implementing the wgpu initialization logic themselves, and that issue – which is the same as this one with (macOS, Metal, wgpu::TextureUsages::COPY_SRC) in place of (Linux, GL, wgpu::TextureUsages::COPY_DST) – is not egui-related.

@fralonra
Copy link

However, nevermind about fralonra/wgshadertoy#3: I had a look at their code and while they're using egui, it looks like they're implementing the wgpu initialization logic themselves, and that issue – which is the same as this one with (macOS, Metal, wgpu::TextureUsages::COPY_SRC) in place of (Linux, GL, wgpu::TextureUsages::COPY_DST) – is not egui-related.

Hi, thanks for mentioning the issue. WgShadertoy is using wgpu::TextureUsages::COPY_SRC to implement screenshot function, which is not supported on some backends. Did not find a way to check whether the usage is supported. Watching gfx-rs/wgpu#3869.

@Wumpf
Copy link
Collaborator

Wumpf commented Jun 17, 2023

@fralonra it got worked around now in #3078 by disabling screenshots for GL backends

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken
Projects
None yet
Development

No branches or pull requests

4 participants