4 Replies Latest reply on May 3, 2011 11:11 AM by Leo van den berg

    Automatically refreshing component s:graphicImage.

    Urska V Newbie

      I am using the s:graphicImage to display image in byte array dynamically. The images are coming with a rate of 25 per second, I would like to display that on the web with the same speed. I tried using a4j:poll, but that is too slow, 2 images per second are displayed. Is there a simple and fast way to rerender dynamic images in real-time automatically?

        • 1. Re: Automatically refreshing component s:graphicImage.
          Aldo Bonzi Novice

          I'm afraid I don't believe there a simple and fast way to rerender dynamic images in real-time automatically.



          • Do you know which is the cause of such an unexpectedly low throughput?

          • Have you tunned up any part of your system? (Seam app 1 2, app server, JVM, OS)

          • Have you monitored (RAM and swap)memory usage while the app is running?

          • Have you monitored processor usage while the app is running?



          Anyways, assuming that your average JPG is 60 KB in size, we have that:
          25 images/s * 60 KB/image = 1500 KB/(s*client) = 12 Mb/(s*client)
          all that without taking into account the overhead coming from transportation protocols, which is quite large.


          Having said that, another approach to the problem(if your domain's constraints allow it) could be serving the images as a video, so there is no time spent in JSF life cycles, Seam interceptors and browser re rendering, plus bandwidth savings. For that task, I've heard that Xuggler could be a good choice, but I've never used it.

          • 2. Re: Automatically refreshing component s:graphicImage.
            Urska V Newbie

            The throughput is not the problem, CPU is used up to 5 percent more while streaming, RAM usage is basically stable. I get a new image in streamedPic variable of type byte array every 50 miliseconds, which makes 20 images per second. The only problem (so far) is when I try to render these images in real time. The combination of a4j:poll and s:graphicImage rerenders around 3 images per second. Is there no web container, component... with javascript function that would take care of refreshing a component carrying a dynamic image every 5 milliseconds for example? Or some library I could use?


            We are not going to have many clients watching the stream at the same time. I want to keep the images I render in memory, so I'm not sure if converting images to a video in real-time could be made on the fly (without storing the image on the disk in the process)?

            • 3. Re: Automatically refreshing component s:graphicImage.
              Urska V Newbie

              Ok, all I need is to refresh the a4j:mediaOutput component or s:graphicImage component every 100 ms. If the browser rerender 5-10 images per second it would be enough. There has to be some way to rerender components, besides a4j:poll. Anyone?

              • 4. Re: Automatically refreshing component s:graphicImage.
                Leo van den berg Master

                Hi,


                You're trying to do an almost impossible task: combining realtime requirements with a browser with JSF. JavaScript has the same restrictions. All existing viewers use a plugin. Consider implementing a simple Applet which does the job without a problem.


                Leo