Skip to content

UI gets frozen when getting new Websocket connection using Custom Plugin #75

Description

@mindnous

Hi @dusty-nv , sorry to bother you again.

I've tried to troubleshoot the freezing issue when I add a new plugin, called "ImageSource". The thing is that the code is running fine in the background, but the UI "somehow" get frozen. And there is no freezing issue even if I open two WebAudioIn nodes as shown below.
However, refreshing the page solve the freezing issue, but it will happen again when I send an image through the Websocket @@

Do you know what might cause this issue? Or is there something wrong with the implementation below?
Note; I follow web_audio.py for reference.

import time
import base64
import numpy as np
import cv2
from nano_llm.web import WebServer
from PIL import Image
from nano_llm import Plugin

class ImageSource(Plugin):
    """
    Recieves audio samples over the websocket from client microphone.
    """
    def __init__(self,
                 image_url: str = './resources/crosswalk-featured.jpg',
                 use_restapi: bool = False,
                 delay: float = 0.5,
                 **kwargs):
        super().__init__(outputs='images', **kwargs)
        self.image_url = image_url
        self.delay = delay
        self.framerate = 0
        self.image = None
        self.use_restapi = use_restapi
        WebServer.add_listener(self.on_websocket)
    
    def on_websocket(self, samples, msg_type=5, **kwargs): 
        """
        Handle websocket messages, specifically image uploads
        
        Args:
            samples (dict/PIL.Image): Received message payload
            msg_type (int): Type of message received
        """
        # Handle BYTES message
        if msg_type in [WebServer.MESSAGE_FILE, WebServer.MESSAGE_IMAGE]:
            # self.image = self.get_image_frombytes(samples)
            self.image = samples
            print('[ImageSource - on_websocket] image shape: ', self.image.size)
            # self.image.save('test.jpg')
            self.output(self.image)
            self.stop_flag = True
            self.send_stats(summary=f"{self.image.size}")
        else:
            return

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions