i-rinat / freshplayerplugin

ppapi2npapi compatibility layer
MIT License
727 stars 52 forks source link

Flash player area flickering #323

Closed hexchain closed 8 years ago

hexchain commented 8 years ago

First, thanks for this amazing work!

I'm having some problem watching videos on bilibili.com (sorry for the Chinese-only site but I cannot seem to reproduce on any other video sites). Sample, click the video area and it'll start playing.

The flash area flickers a lot when playing video (no flickering when paused). Turning off enable_3d seems to be a valid workaround, but if I'm right this also turns off all hardware decoding. Turning on or off compositor has no effect. Using intel or modesetting DDX driver does not affect this problem, too.

I don't have this problem with chromium but there's no hardware decoding in Linux Chromium anyway.

I'm using Arch Linux, fully upgraded.

firefox 45.0.2-1
chromium 50.0.2661.75-1
chromium-pepper-flash 1:21.0.0.216-1
freshplayerplugin-git v0.3.5.r1.g99c5aa1-1
linux 4.5.1-1
xorg-server 1.18.3-1

VGA compatible controller [0300]: Intel Corporation Skylake Integrated Graphics [8086:1916] (rev 07) (prog-if 00 [VGA controller])
    Kernel driver in use: i915
i-rinat commented 8 years ago

Interestingly enough, now that sample video doesn't work anymore in freshplayerplugin, but still works in Chrome.

hexchain commented 8 years ago

Well, I have no problem playing that video in both Firefox and Chromium (except for the flickering in freshplayerplugin). Since it's a Chinese site, maybe there's connectivity issue?

Aetf commented 8 years ago

@hexchain Are you getting flickers even not in fullscreen mode? On my box, it works perfectly if I don't make it fullscreen.

I can play the sample video from US without a problem, and can reproduce the flicker in fullscreen mode. Setting enable_3d=0 does fix the issue, but it breaks the device_scale=1.5 in fullscreen mode.

Related version

Arch Linux

firefox-nightly 49.0a1.20160501-1
google-chrome 50.0.2661.94-1
freshplayerplugin-git v0.3.5.r1.g99c5aa1-1
xorg-server 1.18.3-1
xf86-video-intel 1:2.99.917+636+g562ae1f-1
linux 4.5.1-1

Hardware

00:02.0 VGA compatible controller: Intel Corporation Broadwell-U Integrated Graphics (rev 09)
hexchain commented 8 years ago

@Aetf yes, even not in fullscreen mode.

Plus, I don't have the Xorg DDX driver xf86-video-intel installed according to a note on this page, but it does not seem to affect this issue.

i-rinat commented 8 years ago

Since it's a Chinese site, maybe there's connectivity issue?

It works fine in Chrome, so most probably that's just another bug in freshplayerplugin.

i-rinat commented 8 years ago

Firefox just blocked http://87.245.198.80/ because "web page at 87.245.198.79 has been reported to contain unwanted software". At least, video's now working.

i-rinat commented 8 years ago

Could you try code from use-tripple-buffering branch? I've made GL context there double-buffered.

Also, what flickering looks like? Is it white flashes or black? How often, several times a second, or once in several seconds?

hexchain commented 8 years ago

It's white flash, sometimes once in several seconds then several times a second, seems completely random.

With code in that branch and enable_3d=1, the flash player area is completely black, but I can still interact with the video player and hear sound.

I got these 2 lines in terminal both with code from master and use-tripple-buffering, don't know if relevant:

[fresh 30173] not implemented: PPB_OpenGLES2VertexArrayObject;1.0
[fresh 30173] not implemented: PPB_OpenGLES2DrawBuffers(Dev);1.0
i-rinat commented 8 years ago

the flash player area is completely black, but I can still interact with the video player and hear sound.

@hexchain, what is an output of glxinfo command on your machine?

I got these 2 lines

PepperFlash asks for those interfaces every time. But since they are not required, I didn't implement them. Their absence won't interfere rendering anyhow.

i-rinat commented 8 years ago

Setting enable_3d=0 does fix the issue, but it breaks the device_scale=1.5 in fullscreen mode.

@Aetf, there is a size mismatch in full screen mode indeed. Commit f78f909333c76246db84934f5b69a331ab3c0e03 should fix that.

hexchain commented 8 years ago

Output of glxinfo pasted at http://ix.io/yWw

i-rinat commented 8 years ago

Output of glxinfo

GLXFBConfigs looks exactly the same as on my machine. So, no luck there.

Could you also try again with enable_xrender = 0 in config file? That will disable using of XRender. Maybe it fails somehow.

Aetf commented 8 years ago

@hexchain : The modesetting driver looks interesting, and might be the reason why I only get flicker in fullscreen. But I agree that the driver doesn't look like the root cause for this issue.

@i-rinat :

there is a size mismatch in full screen mode indeed. Commit f78f909 should fix that.

Yes that works. Nice job!

what flickering looks like?

I got the exactly same flicker as hexchain , but only in fullscreen.

Could you try code from use-tripple-buffering branch? I've made GL context there double-buffered.

The player area is black, mouse interaction and sound works fine.

Could you also try again with enable_xrender = 0 in config file?

No use. The same black.

And here is my glxinfo output, which looks mostly the same as hexchain's

i-rinat commented 8 years ago

Found another player that is not fixed with f78f909333c76246db84934f5b69a331ab3c0e03, so 8c5967cb99fc430df4ece1a39f55e0934f1cd2a9 was added.

i-rinat commented 8 years ago

Oh, I've just realized why double-buffering code makes no picture. (And why there were no double buffering before in the code). GLX allows to create double-buffered GLX Pixmap, but glXSwapBuffers() is silently ignored for such pixmaps.

i-rinat commented 8 years ago

OK, next attempt, now in use-second-pixmap-g3d branch. Now there are two sets of Pixmap and Pictures. One of them is used as a buffer.

Has it any effect on flickering?

Aetf commented 8 years ago

That's working! I can't reproduce the flicker any more. Let's see if the patch also works for @hexchain .

hexchain commented 8 years ago

With the use-second-pixmap-g3d code:

I still have that flickering, but much less this time, only once in several seconds.

Also with enable_xrender = 0, the right half of flash player area is black: 1462158362 ^ This does not happen with master branch.

i-rinat commented 8 years ago

right half of flash player area is black

Forgot to remove width division by 2 which was added during debugging. I've pushed fixed version into the master branch as 4732f473f9c71153c59ce9c4835253470b6e9089.

I still have that flickering, but much less this time, only once in several seconds.

I think, I saw it too. But can't reproduce now.

And have no idea why it happens. Before, there was a possibility that drawing thread could erase drawing area before browser thread had a chance to put it onto a screen. Now, with explicit copying, that possibility's eliminated.

i-rinat commented 8 years ago

I tried to save all frames into files, and there are indeed a number of all-white frames. So they are coming from PepperFlash itself. There also no noticable differences in PPB_Graphics3D and PPB_OpenGLES2 calls between normal frames and all-white frames.

i-rinat commented 8 years ago

Added more synchronizations in afb5209b15a65e4e2e671518c81b14ef254c1144.

It could be that even if glFinish() is called and drawing is finished, it takes some time to propagate from GL buffers to X drawables. Adding more synchronization should prevent data race situations, when data is read before it was written. And in my tests it does help.

hexchain commented 8 years ago

Great! Now I don't see any flickering.

i-rinat commented 8 years ago

Good. Let's hope that helps indeed.