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

Slowdown on resize between RC6 and build of June 15, 2014 #223

Closed
jamesst20 opened this issue Jun 15, 2014 · 21 comments
Closed

Slowdown on resize between RC6 and build of June 15, 2014 #223

jamesst20 opened this issue Jun 15, 2014 · 21 comments
Labels

Comments

@jamesst20
Copy link

Hi,

I just discovered this awesome project. A big thanks to the author!

I have downloaded the RC6 and tested the example WebcamViewerExample and it works fine. However, I was curious and built the project as today to check if performance or whatever was better.

Here is the issue I have noticed. With the build of today, if I resize the Window, the WebcamPanel gets really really laggy. On the other hand, with the RC6, I don't have this problem. PS: To test the problem, add one of these : panel.setFillArea(true) or panel.setFitArea(true)

My guess is that the issue is coming from this : d36900b but I didn't check.

I just thought it would be good to know. Is there any way to fix this?

Thanks again!

@sarxos
Copy link
Owner

sarxos commented Jun 15, 2014

Hi @jamesst20,

Thank you for the report.

It seems like painting in the screen buffer, even when the double buffering is enabled, makes it perform much slower than painting on buffered image.

@sarxos
Copy link
Owner

sarxos commented Jun 15, 2014

Adding @syliks to the thread.

Sylwia, can you please confirm? I do not have such experience in Swing, so cannot tell if this is the root cause, plus you did this commit, so you may know it much better :)

@jamesst20
Copy link
Author

@sarxos @syliks I hope she will see because according to her profile, the only activity she had was this commit.

@syliks
Copy link
Contributor

syliks commented Jun 16, 2014

Hi guys, I will look into this later since I do not have much time lately. @jamesst20 can you verify if you have double buffering enabled on the painted panel?http://docs.oracle.com/javase/7/docs/api/javax/swing/JComponent.html#isDoubleBuffered%28%29Od: "jamesst20" <notifications@github.com>Do: "sarxos/webcam-capture" <webcam-capture@noreply.github.com>; Wysłane: 22:52 Niedziela 2014-06-15Temat: Re: [webcam-capture] Slowdown on resize between RC6 and build of June 15, 2014 (#223)@sarxos @syliks I hope she will see because according to her profile, the only activity she had was this commit.

—Reply to this email directly or view it on GitHub.

@jamesst20
Copy link
Author

@syliks
I tried to enable it and disable it but it makes no diffence. Also, I believe you made it to be enabled by default.

Thanks

Edit : Do you think it will be a very long to fix or it is just a very small error?

@jamesst20
Copy link
Author

@sarxos @syliks

Please :) I believe this should be a priority since the resizing makes it pretty much unusable :/

@sarxos
Copy link
Owner

sarxos commented Jun 19, 2014

@jamesst20,

I tried to reproduce the issue on my Ubuntu laptop, but no luck - I constantly have rendering performance around 20-40 repaints per second, no matter if I have the window very small or full screen, so either my screen resolution is too small to observe the problem (1336x768), or it does not occur on Ubuntu Linux...

I guess we will need wait for Sylwia or I can rework the code to use the old painting code and you will verify if it fixed the problem or not.

@jamesst20
Copy link
Author

@sarxos

Hi,

I tried to confirm if the issue was there in Ubuntu but sadly it looks like my Webcam isn't working very well with VMWare Workstation. The camera turns on I know it because of the white led but there is no image. I tried a random camera app from the Ubuntu Store and same problem --> Not a library problem I guess.

Thanks

@sarxos
Copy link
Owner

sarxos commented Jun 20, 2014

Today I will try to reproduce this issue on Windows 7. Will keep you informed.

@jamesst20
Copy link
Author

@sarxos

Thanks :) This is odd because the FPS is always 30 but it becomes laggy.

@sarxos
Copy link
Owner

sarxos commented Jun 20, 2014

The fps describes how fast frames are being processed by the camera. The
panel rendering speed is something different.

@jamesst20
Copy link
Author

@sarxos

You're right, this is definitively the panel repainting because even the "FPS" is refreshed less often if I make the window bigger.

I have tested on Max OS X Mavericks and the issue is there aswell.

Thanks

@sarxos
Copy link
Owner

sarxos commented Jun 20, 2014

@jamesst20,

I managed to set up everything on Win7 and performed small test. Here is the output:

DEBUG: PPS perf: 37.0 at 640x480
DEBUG: PPS perf: 28.6 at 640x480
DEBUG: PPS perf: 29.4 at 640x480
DEBUG: PPS perf: 37.0 at 640x480
DEBUG: PPS perf: 31.3 at 640x480
DEBUG: PPS perf: 27.8 at 640x480
DEBUG: PPS perf: 29.4 at 640x480
DEBUG: PPS perf: 33.3 at 640x480
DEBUG: PPS perf: 30.3 at 640x480
DEBUG: PPS perf: 23.3 at 640x480
DEBUG: PPS perf: 7.2 at 1920x1028
DEBUG: PPS perf: 16.7 at 1920x1028
DEBUG: PPS perf: 15.2 at 1920x1028
DEBUG: PPS perf: 18.9 at 1920x1028
DEBUG: PPS perf: 22.2 at 1920x1028
DEBUG: PPS perf: 16.9 at 1920x1028
DEBUG: PPS perf: 20.0 at 1920x1028
DEBUG: PPS perf: 23.8 at 1920x1028
DEBUG: PPS perf: 23.8 at 1920x1028
DEBUG: PPS perf: 21.3 at 1920x1028
DEBUG: PPS perf: 23.3 at 1920x1028
DEBUG: PPS perf: 25.6 at 1920x1028
DEBUG: PPS perf: 21.3 at 1920x1028

As you can see, the painting performance with panel size 1920x1028 is about one third smaller than the one with size 640x480. I wouldn't call it laggy since ~20 repaints per second is pretty good. I will try to gather some better (from statistical point of view) results for the newest and older releases, but now I need to take care of some other business.

You can fetch the source code and play with it a little bit as well.

@jamesst20
Copy link
Author

@sarxos

Have you tried looking the panel instead of looking at debug ? Because I don't say it is laggy because of the FPS number, I say it is VERY laggy because of the image. It is not smooth at all.

I am going to record a video to show you, hold on

@jamesst20
Copy link
Author

@sarxos @syliks

Please, take a minute to watch the whole video describing the issue.

https://www.youtube.com/watch?v=TfAdc6utOVQ

@sarxos
Copy link
Owner

sarxos commented Jun 20, 2014

Hi.

I will take a look at this video.

The debug output i posted presents image painting rate, not fps. It's
measured between two consecutive panel repaint operations.

@jamesst20
Copy link
Author

@sarxos

Have you seen the video? What could causes that?

@sarxos
Copy link
Owner

sarxos commented Jun 20, 2014

Hi. Yes. The lag is terrible. I guess that I'm not able to observe it on my PC (on both Ubuntu and Windows 7) is because JVM may be using some sort of hardware acceleration on my machine.

In the meantime I replaced part of the code that Sylwia changed by the old one trying to keep overall functionality untouched. Can you please try this JAR and let me know if it fixed your issue?

https://oss.sonatype.org/content/repositories/snapshots/com/github/sarxos/webcam-capture/0.3.10-SNAPSHOT/webcam-capture-0.3.10-20140620.212525-28.jar

Regards

@jamesst20
Copy link
Author

@sarxos
YES! This works perfectly :)

Will you merge this into the official repo :D ?

Otherwise, how do you get that "Hardware Acceleration", what am I missing ?

@sarxos
Copy link
Owner

sarxos commented Jun 20, 2014

Great!

I would like you to test this last JAR (I want to verify that my last changes did not break the fix) and I will merge this as soon as you confirm it's ok.

https://oss.sonatype.org/content/repositories/snapshots/com/github/sarxos/webcam-capture/0.3.10-SNAPSHOT/webcam-capture-0.3.10-20140620.220628-29.jar

Java guys implemented quite fancy API which hides the rendering complexity and all the details causing the image to be accelerated when we are not even aware of this fact. There is no option to enable or disable it, but one need to use specific "hacks" to make use of it. Like in this issue, when drawing image on screen is more time consuming than drawing image into another image, and then on screen ;P

@jamesst20
Copy link
Author

@sarxos

Still fixed :)

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

3 participants