Skip to content

Getting Started with fullscreen crashes on macOS Big Sur 11.1 #1366

Open
@anatawa12

Description

I've just added the line .fullscreen(true) from Getting Started Spinning Square.

But it shows a fullscreen white window and the app was crashed when launches this or clicks the window.

All tools and libraries are the latest releases at this issue creation.

  • platform: macOS BigSur version 11.1
  • rustc 1.49.0 (e1884a8e3 2020-12-29)
  • cargo 1.49.0 (d00d64df9 2020-12-05)
  • piston = "0.52.1"
  • piston2d-graphics = "0.39.0"
  • pistoncore-glutin_window = "0.68.0"
  • piston2d-opengl_graphics = "0.77.0"
main.rs
extern crate glutin_window;
extern crate graphics;
extern crate opengl_graphics;
extern crate piston;

use glutin_window::GlutinWindow as Window;
use opengl_graphics::{GlGraphics, OpenGL};
use piston::event_loop::{EventSettings, Events};
use piston::input::{RenderArgs, RenderEvent, UpdateArgs, UpdateEvent};
use piston::window::WindowSettings;

pub struct App {
    gl: GlGraphics, // OpenGL drawing backend.
    rotation: f64,  // Rotation for the square.
}

impl App {
    fn render(&mut self, args: &RenderArgs) {
        use graphics::*;

        const GREEN: [f32; 4] = [0.0, 1.0, 0.0, 1.0];
        const RED: [f32; 4] = [1.0, 0.0, 0.0, 1.0];

        let square = rectangle::square(0.0, 0.0, 50.0);
        let rotation = self.rotation;
        let (x, y) = (args.window_size[0] / 2.0, args.window_size[1] / 2.0);

        self.gl.draw(args.viewport(), |c, gl| {
            // Clear the screen.
            clear(GREEN, gl);

            let transform = c
                .transform
                .trans(x, y)
                .rot_rad(rotation)
                .trans(-25.0, -25.0);

            // Draw a box rotating around the middle of the screen.
            rectangle(RED, square, transform, gl);
        });
    }

    fn update(&mut self, args: &UpdateArgs) {
        // Rotate 2 radians per second.
        self.rotation += 2.0 * args.dt;
    }
}

fn main() {
    // Change this to OpenGL::V2_1 if not working.
    let opengl = OpenGL::V3_2;

    // Create an Glutin window.
    let mut window: Window = WindowSettings::new("spinning-square", [200, 200])
        .fullscreen(true) // just added here
        .graphics_api(opengl)
        .exit_on_esc(true)
        // tried here too but same error
        .build()
        .unwrap();

    // Create a new game and run it.
    let mut app = App {
        gl: GlGraphics::new(opengl),
        rotation: 0.0,
    };

    let mut events = Events::new(EventSettings::new());
    while let Some(e) = events.next(&mut window) {
        if let Some(args) = e.render_args() {
            app.render(&args);
        }

        if let Some(args) = e.update_args() {
            app.update(&args);
        }
    }
}
console output
/Users/anatawa12/.cargo/bin/cargo run --color=always --package photo-frame-rs --bin photo-frame-rs
    Finished dev [unoptimized + debuginfo] target(s) in 0.36s
     Running `target/debug/photo-frame-rs`
thread 'main' panicked at 'assertion failed: `(left != right)`
  left: `0x0`,
 right: `0x0`', /Users/anatawa12/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.24.0/src/platform_impl/macos/app.rs:106:13
stack backtrace:
   0: rust_begin_unwind
             at /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca/library/std/src/panicking.rs:495:5
   1: std::panicking::begin_panic_fmt
             at /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca/library/std/src/panicking.rs:437:5
   2: winit::platform_impl::platform::app::maybe_dispatch_device_event
             at /Users/anatawa12/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.24.0/src/platform_impl/macos/app.rs:106:13
   3: winit::platform_impl::platform::app::send_event
             at /Users/anatawa12/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.24.0/src/platform_impl/macos/app.rs:52:13
   4: <unknown>
   5: <unknown>
   6: <() as objc::message::MessageArguments>::invoke
             at /Users/anatawa12/.cargo/registry/src/github.com-1ecc6299db9ec823/objc-0.2.7/src/message/mod.rs:128:17
   7: objc::message::platform::send_unverified
             at /Users/anatawa12/.cargo/registry/src/github.com-1ecc6299db9ec823/objc-0.2.7/src/message/apple/mod.rs:27:9
   8: objc::message::send_message
             at /Users/anatawa12/.cargo/registry/src/github.com-1ecc6299db9ec823/objc-0.2.7/src/message/mod.rs:178:5
   9: winit::platform_impl::platform::event_loop::EventLoop<T>::run_return
             at /Users/anatawa12/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.24.0/src/platform_impl/macos/event_loop.rs:106:25
  10: <winit::event_loop::EventLoop<T> as winit::platform::run_return::EventLoopExtRunReturn>::run_return
             at /Users/anatawa12/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.24.0/src/platform/run_return.rs:56:9
  11: glutin_window::GlutinWindow::poll_events
             at /Users/anatawa12/.cargo/registry/src/github.com-1ecc6299db9ec823/pistoncore-glutin_window-0.68.0/src/lib.rs:271:9
  12: glutin_window::GlutinWindow::poll_event
             at /Users/anatawa12/.cargo/registry/src/github.com-1ecc6299db9ec823/pistoncore-glutin_window-0.68.0/src/lib.rs:237:17
  13: <glutin_window::GlutinWindow as window::Window>::poll_event
             at /Users/anatawa12/.cargo/registry/src/github.com-1ecc6299db9ec823/pistoncore-glutin_window-0.68.0/src/lib.rs:509:49
  14: event_loop::Events::next
             at /Users/anatawa12/.cargo/registry/src/github.com-1ecc6299db9ec823/pistoncore-event_loop-0.52.0/src/lib.rs:253:38
  15: photo_frame_rs::main
             at ./src/main.rs:68:25
  16: core::ops::function::FnOnce::call_once
             at /Users/anatawa12/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Process finished with exit code 101

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions