Skip to content

0.14.0 - video image flicker and disappear but rev at "49a300ab38a86d548b5a607113827ac9efdcf2f9" don't have this problem #3190

@asxlon

Description

@asxlon

Is your issue REALLY a bug?

  • My issue is indeed a bug!
  • I am not crazy! I will not fill out this form just to ask a question or request a feature. Pinky promise.

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?

0.14.0 - video image flicker and disappear but rev at "49a300ab38a86d548b5a607113827ac9efdcf2f9" don't have this problem

`
use crate::app::h264_file_play::h264_file_read::UiInput;
use flume::Sender;
use iced::{
widget::{self, column, container, image, row},
window, Element, Font,
Length::Fill,
Pixels, Settings, Size, Subscription, Task, Theme,
};
use ringbuf::{storage::Heap, traits::, wrap::caching::Caching, HeapRb, SharedRb};
use std::{collections::HashMap, sync::Arc};
use tracing::
;

pub fn start() {
let window_setting = window::Settings::default();
iced::application(H264FileView::new, H264FileView::update, H264FileView::view)
.theme(H264FileView::theme)
.settings(Settings {
default_text_size: Pixels(15.),
..Settings::default()
})
.window(window_setting)
.font(include_bytes!("../../../fonts/icons.ttf").as_slice())
.font(include_bytes!("../../../fonts/PingFang_Light.ttf").as_slice())
.default_font(Font::with_name("PingFang SC"))
.subscription(H264FileView::subscription)
.run()
.unwrap();
}

#[derive(Debug, Clone)]
pub enum Message {
ChannelInit(Sendersuper::h264_file_read::UiInput),
ChannelEvent,
ChannelImage(Vec<(Vec, i32, i32)>),
WindowResized(window::Id, Size),
WindowOpened,
IgnoreEvent,
TickEvent,
}
pub struct H264FileView {
pub image: iced::widget::image::Handle,
pub buffer: HashMap<String, Caching<Arc<SharedRb<Heapimage::Handle>>, false, true>>,
pub task_sender: Option<Sendersuper::h264_file_read::UiInput>,
}

impl H264FileView {
fn new() -> (Self, Task) {
let self_target = Self {
image: iced::widget::image::Handle::from_bytes(vec![0, 0, 0]),
task_sender: None,
buffer: HashMap::default(),
};
(self_target, Task::batch([widget::operation::focus_next()]))
// (self_target, Task::batch([widget::focus_next()]))
}

fn update(&mut self, message: Message) -> Task<Message> {
    match message {
        Message::ChannelInit(task_sender) => {
            self.task_sender = Some(task_sender);
        }
        Message::ChannelImage(_) => {}
        Message::WindowResized(id, size) => {
            info!("window size changed: {} {:?}", id, size);
        }
        Message::WindowOpened => {
            if let Some(task_sender) = &self.task_sender {
                let rb = HeapRb::<image::Handle>::new(100);
                let (producer, consumer) = rb.split();
                self.buffer.insert("image".into(), consumer);
                let _ = task_sender.send(UiInput::WindowOpened(producer));
            }
        }
        Message::TickEvent => {
            for (_topic, consumer) in self.buffer.iter_mut() {
                if let Some(cache_data) = consumer.try_pop() {
                    self.image = cache_data;
                }
            }
        }
        _ => {}
    }
    return Task::none();
}

fn subscription(&self) -> Subscription<Message> {
    Subscription::batch([
        window::events().map(|event| match event.1 {
            iced::window::Event::Resized(size) => Message::WindowResized(event.0, size),
            #[allow(unused)]
            iced::window::Event::Opened { position, size } => Message::WindowOpened,
            _ => Message::IgnoreEvent,
        }),
        iced::time::every(iced::time::milliseconds(20)).map(|_| Message::TickEvent),
        Subscription::run(super::h264_file_read::start_worker),
    ])
}

fn view(&self) -> Element<'_, Message> {
    let main_block = row![container(image(self.image.clone()))
        .height(Fill)
        .width(Fill),]
    .spacing(2);
    column![main_block].into()
}

fn theme(&self) -> Theme {
    Theme::Dark
}

}

`

What is the expected behavior?

at the rev of 49a300a, it doesn't have this issue.

`
iced = { git = "https://github.com/iced-rs/iced.git", rev = "49a300ab38a86d548b5a607113827ac9efdcf2f9", default-features = false, features = [
"svg",
"wgpu",

Screencast.from.2026.01.09.16.16.07.webm
"crisp",
"web-colors",
"auto-detect-theme",
"thread-pool",
"image",
"advanced",
"tokio",

] }
`

Version

crates.io release

Operating System

Linux

Do you have any log output?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions