i-rinat / freshplayerplugin

ppapi2npapi compatibility layer
MIT License
727 stars 52 forks source link

Broken video with hwdec enabled #307

Closed i-rinat closed 6 years ago

i-rinat commented 8 years ago

ppb_video_decoder_decode() is feeded sometimes with bitstream buffers in a wrong order (i.e. 5, 6, 1, 2, 3, 4, 7, 8 and so on). Could be related to task reordering in a message loop.

sarnex commented 8 years ago

I'm also experiencing this issue. Is there anything I could do to help? The video dies seemingly every time with hwdec enabled. For now i've just disabled hwdec but I would really like to use it.

i-rinat commented 8 years ago

It would be nice if someone fixed that instead of me :-)

Aside from that, there is not so much to do. I've done some debugging, and the cause is task reordering indeed. There is a trick in nested loop handling, where a task with a specified depth level is expected. To make that work, tasks with lower levels are rescheduled to "now + 10 ms". That effectively breaks their order. I think solution is to figure out other way of task queue handling, which won't break other things. A subtle place.

i-rinat commented 8 years ago

Should be fixed by 7ba5f2de0e7a8b6f6bbb1e66abab86300dcc4db9.

sarnex commented 8 years ago

Sorry, it is not fixed. I still get a black screen and then spam of radeon: The kernel rejected CS, see dmesg for more information.. dmesg shows:

[3528.748169] [drm:radeon_uvd_cs_parse [radeon]] *ERROR* Invalid UVD handle 0xc2800013!
[ 3528.748180] [drm:radeon_cs_ioctl [radeon]] *ERROR* Invalid command stream !
i-rinat commented 8 years ago

I still get a black screen and <...>

Try to dump bitstream with code from dump-bitstream branch. It will save raw video data to files in /tmp. When you find a video which triggers the bug, try to play it with mpv or mplayer, with software decoder. What under test is: will it be decoded without glitches or not.

There are two cases. It could be freshwrapper breaking the video. Or it could be that hw decoder can't decode it.

sarnex commented 8 years ago

Ok, I have the video. If i play it with mpv with --hwdec=vdpau --vo=vpdau, the video looks correct and I get no errors. If i play with just mpv (software), it also looks fine. So, i cannot reproduce the errors and black screen without freshplayerplugin. does this mean its a freshplayerplugin bug? thanks

i-rinat commented 8 years ago

does this mean its a freshplayerplugin bug?

Yeah, most probably.

So, just to reiterate. You've seen visual glitch in Flash-based video player, which caused mentioned error messages. Then found corresponding .bitstream dump in /tmp, and tried to play it in a player with both software and hardware decoding modes. And both tries were decoded correctly. Right?

In that case there is something with freshplayerplugin, but I can't say what exactly causes it. Previous issues were due to reordering of bytes in bitstream, which resulted in a broken H.264 data.

sarnex commented 8 years ago

Yes, but it is not really visual glitches, the screen just goes black while the sound continues.

i-rinat commented 8 years ago

but it is not really visual glitches, the screen just goes black

Then it's a different issue.

I've also read again error message you posted. "Invalid UVD handle 0xc2800013!" looks very strange. It's not like an error in data, but an error in metadata. UVD handles are low-level stuff. Neither ffmpeg, nor freshwrapper uses them. Perhaps, there were some stream shift, or some bytes were lost, which caused misinterpretation of data. I have no idea what causes it, and how to fix it.

sarnex commented 8 years ago

Ok, thanks for looking. Let me know if I can do anything to help.

i-rinat commented 8 years ago

@sarnex, does that still happen?

sarnex commented 7 years ago

Sorry about the super late reply, it looks like it's fixed. Thanks.

i-rinat commented 7 years ago

it looks like it's fixed

Cool.

"If you wait by the river long enough, the fixes of the bugs will float by..."