Repository: servo/servo
File: components/script/dom/html/htmlmediaelement.rs (Rust)

Code before:
        &mut self,
        player_id: usize,
        task_source: SendableTaskSource,
        weak_video_renderer: Weak<Mutex<MediaFrameRenderer>>,
    ) {
        self.player_id = Some(player_id);

        let (glplayer_id, image_receiver) = self
            .player_context
            .glplayer_thread_sender
            .as_ref()
            .map(|sender| {
                let (image_sender, image_receiver) = ipc::channel::<GLPlayerMsgForward>().unwrap();
                sender
                    .send(GLPlayerMsg::RegisterPlayer(image_sender))
                    .unwrap();
                match image_receiver.recv().unwrap() {
                    GLPlayerMsgForward::PlayerId(id) => (Some(id), Some(image_receiver)),
                    _ => unreachable!(),
                }
            })
            .unwrap_or((None, None));

        self.glplayer_id = glplayer_id;

        if let Some(image_receiver) = image_receiver {
            ROUTER.add_typed_route(
                image_receiver,
                Box::new(move |message| {
                    let message = message.unwrap();
                    let weak_video_renderer = weak_video_renderer.clone();

                    task_source.queue(task!(handle_glplayer_message: move || {
                        trace!("GLPlayer message {:?}", message);

                        let Some(video_renderer) = weak_video_renderer.upgrade() else {
                            return;
                        };

                        match message {
                            GLPlayerMsgForward::Lock(sender) => {
                                if let Some(holder) = video_renderer
                                    .lock()
                                    .unwrap()
                                    .current_frame_holder
                                    .as_mut() {
                                        holder.lock();
                                        sender.send(holder.get()).unwrap();
                                    };
                            },
                            GLPlayerMsgForward::Unlock() => {

Review comment (suggestion):
```suggestion
        let Some(image_receiver) = image_receiver else { return };
```

Code after:
        &mut self,
        player_id: usize,
        task_source: SendableTaskSource,
        weak_video_renderer: Weak<Mutex<MediaFrameRenderer>>,
    ) {
        self.player_id = Some(player_id);

        let (glplayer_id, image_receiver) = self
            .player_context
            .glplayer_thread_sender
            .as_ref()
            .map(|sender| {
                let (image_sender, image_receiver) = ipc::channel::<GLPlayerMsgForward>().unwrap();
                sender
                    .send(GLPlayerMsg::RegisterPlayer(image_sender))
                    .unwrap();
                match image_receiver.recv().unwrap() {
                    GLPlayerMsgForward::PlayerId(id) => (Some(id), Some(image_receiver)),
                    _ => unreachable!(),
                }
            })
            .unwrap_or((None, None));

        self.glplayer_id = glplayer_id;

        let Some(image_receiver) = image_receiver else {
            return;
        };

        ROUTER.add_typed_route(
            image_receiver,
            Box::new(move |message| {
                let message = message.unwrap();
                let weak_video_renderer = weak_video_renderer.clone();

                task_source.queue(task!(handle_glplayer_message: move || {
                    trace!("GLPlayer message {:?}", message);

                    let Some(video_renderer) = weak_video_renderer.upgrade() else {
                        return;
                    };

                    match message {
                        GLPlayerMsgForward::Lock(sender) => {
                            if let Some(holder) = video_renderer
                                .lock()
                                .unwrap()
                                .current_frame_holder
                                .as_mut() {
                                    holder.lock();
                                    sender.send(holder.get()).unwrap();