servo / surfman

Accelerated offscreen graphics for WebGL
Apache License 2.0
173 stars 84 forks source link

Spurious test failure of platform::unix::wayland::tests::test_depth_and_stencil #288

Closed jschwe closed 6 months ago

jschwe commented 6 months ago

The following assert in the test fails sometimes (approx. 1 out of 5 times):

    unsafe {
        let framebuffer_object = device
            .context_surface_info(&depth_context)
            .unwrap()
            .unwrap()
            .framebuffer_object;
        gl.BindFramebuffer(gl::FRAMEBUFFER, framebuffer_object);
        gl.Viewport(0, 0, 640, 480);

        gl.ClearDepth(0.5);
        gl.Clear(gl::DEPTH_BUFFER_BIT);

        let mut depth_value: f32 = -1.0;
        gl.ReadPixels(
            0,
            0,
            1,
            1,
            gl::DEPTH_COMPONENT,
            gl::FLOAT,
            (&mut depth_value) as *mut f32 as *mut c_void,
        );
        // Note: edited the assertion to output the actual value.
        assert!(approx_eq(depth_value, 0.5), "actual depth value was {}, but expected 0.5", depth_value);
    }

Output:

---- platform::unix::wayland::tests::test_depth_and_stencil stdout ----
thread 'platform::unix::wayland::tests::test_depth_and_stencil' panicked at surfman/src/platform/unix/wayland/../../../tests.rs:785:9:
actual depth value was NaN, but expected 0.5

Tested on Fedora 40.