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

White Screen. #1338

Open
2 tasks done
ghost opened this issue May 8, 2022 · 8 comments
Open
2 tasks done

White Screen. #1338

ghost opened this issue May 8, 2022 · 8 comments
Labels

Comments

@ghost
Copy link

ghost commented May 8, 2022

Is there an existing issue for this?

  • I have searched the existing issues.

Is this issue related to iced?

  • My hardware is compatible and my graphics drivers are up-to-date.

What happened?

I have wrote the following file

use iced::{
    canvas::{Cache, Cursor, Geometry, Path},
    executor, time,
    widget::canvas::{
        event::{self, Event},
        Program,
    },
    Application, Color, Command, Element, Point, Rectangle, Settings, Subscription, Canvas,
};

struct Example;

#[derive(Debug)]
enum Message {}

#[derive(Debug)]
struct ProgramCanvas {
    cache: Cache,
}

impl Application for Example {
    type Executor = executor::Default;
    type Message = Message;
    type Flags = bool;

    fn new(_flags: Self::Flags) -> (Example, Command<Self::Message>) {
        (Example, Command::none())
    }

	fn title(&self) -> String {
		String::from("Title")
	}

	fn update(&mut self ,_: Self::Message) -> Command<Self::Message> {
		Command::none()
	}

    fn view(&mut self) -> Element<Self::Message> {
        use iced::{Container, Length};
        Canvas::new(ProgramCanvas::new())
        .width(Length::Fill)
        .height(Length::Fill)
        .into()
    }
}

impl ProgramCanvas {
    fn new() -> Self {
        Self {
            cache: Cache::new(),
        }
    }
}

impl Program<Message> for ProgramCanvas {
    fn draw(&self, bounds: Rectangle, _cursor: Cursor) -> Vec<Geometry> {
        let chip_view = self.cache.draw(bounds.size(), |frame| {
            let space = Path::rectangle(Point::ORIGIN, frame.size());
            frame.fill(&space, Color::BLACK);
            log::info!("DRAWING");
            frame.translate(frame.center() - Point::ORIGIN);
        });
        vec![chip_view]
    }
}

pub fn main() -> iced::Result {
    Example::run(Settings {
        id: Some(String::from("Some")),
        window: iced::window::Settings {
            size: (64 * 15, 32 * 15),
            min_size: Some((64 * 15, 32 * 15)),
            max_size: Some((64 * 15, 32 * 15)),
            resizable: false,
            ..iced::window::Settings::default()
        },
        flags: false,
        default_font: None,
        default_text_size: 20,
        text_multithreading: false,
        antialiasing: true,
        exit_on_close_request: true,
        try_opengles_first: false,
    })
}

with the following Cargo.toml

[package]
name = "example"
version = "0.1.0"
edition = "2021"

[dependencies]
rand = "0.8.4"
iced = { version = "~0.4" , features = ["canvas", "tokio"] }
iced_native = "~0.4"
rodio = "0.15.0"
log = "0.4.16"
env_logger = "0.9.0"
builder-pattern = "0.4.2"
byteorder = "1.4.3"

And I am only getting a white screen.

What is the expected behavior?

A black screen

Version

master

Operative System

Linux

Do you have any log output?

No response

@ghost ghost added the bug Something isn't working label May 8, 2022
@hecrj
Copy link
Member

hecrj commented May 8, 2022

  • Do any of the Canvas examples work for you (e.g. clock, solar_system,game_of_life...)?
  • Is this the simplest example possible? Are the unrelated dependencies necessary to reproduce the issue? What about the canvas::Cache?
  • Does disabling antialiasing help in any way? What happens if you enable the glow feature in your Cargo.toml?

@ghost
Copy link
Author

ghost commented May 13, 2022

@hecrj

The example clock is a white screen.
The example game_of_life is no working properly, does no show any cell.
The example solar system is a white screen.

The Cargo.toml can be reduced to

[package]
name = "example"
version = "0.1.0"
edition = "2021"

[dependencies]
iced = { version = "~0.4" , features = ["canvas", "tokio"] }
iced_native = "~0.4"
log = "0.4.16"
env_logger = "0.9.0"

The disabling of anti-aliasing does in fact solve the problem.
The enabling to the feature glow does in fact also solve the problem.
And the mixing of two also solve the problem.

@xTekC
Copy link
Contributor

xTekC commented Jun 19, 2022

@hecrj
On Arch Linux I have solved this problem before when using iced.
Adding the "glow" feature to each iced project while using Arch Linux and likely other Linux distros solves the problem and everything works properly.

Close issue

@scottrick
Copy link

I was seeing the same issue (although solar_system was black instead of white). Adding feature "glow" fixed it for me. Running Ubuntu 22.04.

@silven
Copy link

silven commented Oct 2, 2022

I checked out iced for the first time today. I also had the issue that every Canvas was just white. Activating "glow" feature makes it work. Also running ubuntu 22.04.

@MichalLebeda
Copy link
Contributor

MichalLebeda commented Oct 16, 2022

@hecrj
Close issue

No,
It does not fix the problem, it just switches to OpenGL.

Having same problem on Arch. Glow works as others mentioned

@greatest-ape
Copy link
Contributor

I’m having reports of what is likely the same issue: greatest-ape/OctaSine#136 (comment)

@jw3
Copy link

jw3 commented Sep 12, 2023

At 0.10 without glow, is there a solution other than disabling antialiasing?

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

No branches or pull requests

7 participants