ue4plugins / VlcMedia

Media Framework plug-in using the Video LAN Codec (libvlc).
BSD 3-Clause "New" or "Revised" License
267 stars 145 forks source link

Play video freezes game in shipping mode on 4.18 #46

Closed Arisego closed 7 years ago

Arisego commented 7 years ago

I am not sure if I miss something. Everything works fine both in Editor and Development build. But when I build project in shipping mode, game freezes every-time I try to play some video.

btw, I am on Win7x64, UE 4.18.0.

Thank you

Arisego commented 7 years ago

I opened vlc's log on shipping but got nothing helpful

-- logger module started -- core debug: VLC media player - 3.0.0-git Vetinari core debug: Copyright © 1996-2017 the VideoLAN team core debug: revision 2.2.0-git-14505-g1467f40402 core debug: configured with ../extras/package/win32/../../../configure '--enable-update-check' '--enable-lua' '--enable-faad' '--enable-flac' '--enable-theora' '--enable-twolame' '--enable-avcodec' '--enable-merge-ffmpeg' '--enable-dca' '--enable-mpc' '--enable-libass' '--enable-x264' '--enable-schroedinger' '--enable-realrtsp' '--enable-live555' '--enable-dvdread' '--enable-shout' '--enable-goom' '--enable-caca' '--enable-qt' '--enable-skins2' '--enable-sse' '--enable-mmx' '--enable-libcddb' '--enable-zvbi' '--disable-telx' '--enable-nls' '--host=x86_64-w64-mingw32' '--enable-debug' 'host_alias=x86_64-w64-mingw32' 'PKG_CONFIG_LIBDIR=/home/jenkins/workspace/vlc-nightly/vlc-nightly-win64-x86_64/vlc/contrib/x86_64-w64-mingw32/lib/pkgconfig' core debug: using multimedia timers as clock source core debug: min period: 1 ms, max period: 1000000 ms core debug: searching plug-in modules core debug: ignoring plugins cache file core debug: recursively browsing F:\Test\WindowsNoEditor\StreamPlay\Plugins\VlcMedia\ThirdParty\vlc\Win64\plugins' core debug: plug-ins loaded: 481 modules core debug: looking for logger module matching "any": 2 candidates file debug: opening logfilevlc-log.txt' core debug: using logger module "file" core debug: translation test: code is "C" core debug: looking for keystore module matching "memory": 3 candidates core debug: using keystore module "memory" core debug: CPU has capabilities MMX MMXEXT SSE SSE2 SSE3 SSSE3 SSE4.1 SSE4.2 FPU -- logger module stopped --

Arisego commented 7 years ago

And UE_LOG also gives no help

2017-11-09 15:40:46,181 INFO Initialized LibVLC 3.0.0-git Vetinari (2.2.0-git-14505-g1467f40402 - gcc version 6.2.0 (GCC)) 2017-11-09 15:40:48,489 INFO mmdevice: cannot initialize COM (error 0x80010106) 2017-11-09 15:40:48,811 INFO LibVLC event: Media Parsed Changed 2017-11-09 15:40:48,811 INFO LibVLC event: Player Playing 2017-11-09 15:40:49,321 INFO mpeg4audio: AAC channels: 2 samplerate: 48000 2017-11-09 15:40:49,322 INFO faad: decoded zero sample 2017-11-09 15:40:49,322 INFO StaticAudioSetupCallback: Format=S16N Rate=48000 Channels=2 2017-11-09 15:40:49,481 INFO freetype: DirectWrite initialization failed. Falling back to GDI/Uniscribe 2017-11-09 15:40:49,486 INFO StaticVideoSetupCallback: Chroma=DX11 Dim=1280x720 2017-11-09 15:40:49,486 INFO vmem: video format setup failure (no pictures) 2017-11-09 15:40:49,486 INFO core: video output creation failed 2017-11-09 15:40:49,487 INFO core: failed to create video output 2017-11-09 15:40:49,488 INFO freetype: DirectWrite initialization failed. Falling back to GDI/Uniscribe 2017-11-09 15:40:49,493 INFO StaticVideoSetupCallback: Chroma=DXA9 Dim=1280x720 2017-11-09 15:40:49,493 INFO vmem: video format setup failure (no pictures) 2017-11-09 15:40:49,493 INFO core: video output creation failed 2017-11-09 15:40:49,494 INFO core: failed to create video output 2017-11-09 15:40:49,496 INFO freetype: DirectWrite initialization failed. Falling back to GDI/Uniscribe 2017-11-09 15:40:49,500 INFO StaticVideoSetupCallback: Chroma=I420 Dim=1280x738 2017-11-09 15:40:49,501 INFO vmem: video format setup failure (no pictures) 2017-11-09 15:40:49,501 INFO core: video output creation failed 2017-11-09 15:40:49,501 INFO core: failed to create video output 2017-11-09 15:40:49,503 INFO freetype: DirectWrite initialization failed. Falling back to GDI/Uniscribe 2017-11-09 15:40:49,508 INFO StaticVideoSetupCallback: Chroma=I420 Dim=1280x738 2017-11-09 15:40:49,508 INFO vmem: video format setup failure (no pictures) 2017-11-09 15:40:49,508 INFO core: video output creation failed 2017-11-09 15:40:49,509 INFO core: failed to create video output 2017-11-09 15:40:49,511 INFO freetype: DirectWrite initialization failed. Falling back to GDI/Uniscribe 2017-11-09 15:40:49,515 INFO StaticVideoSetupCallback: Chroma=I420 Dim=1280x738 2017-11-09 15:40:49,515 INFO vmem: video format setup failure (no pictures) 2017-11-09 15:40:49,516 INFO core: video output creation failed 2017-11-09 15:40:49,516 INFO core: failed to create video output 2017-11-09 15:40:49,518 INFO freetype: DirectWrite initialization failed. Falling back to GDI/Uniscribe 2017-11-09 15:40:49,523 INFO StaticVideoSetupCallback: Chroma=I420 Dim=1280x738 2017-11-09 15:40:49,523 INFO vmem: video format setup failure (no pictures) 2017-11-09 15:40:49,523 INFO core: video output creation failed 2017-11-09 15:40:49,524 INFO core: failed to create video output 2017-11-09 15:40:49,525 INFO freetype: DirectWrite initialization failed. Falling back to GDI/Uniscribe 2017-11-09 15:40:49,530 INFO StaticVideoSetupCallback: Chroma=I420 Dim=1280x738 2017-11-09 15:40:49,530 INFO vmem: video format setup failure (no pictures) 2017-11-09 15:40:49,530 INFO core: video output creation failed 2017-11-09 15:40:49,531 INFO core: failed to create video output 2017-11-09 15:40:49,532 INFO freetype: DirectWrite initialization failed. Falling back to GDI/Uniscribe 2017-11-09 15:40:49,537 INFO StaticVideoSetupCallback: Chroma=I420 Dim=1280x738 2017-11-09 15:40:49,537 INFO vmem: video format setup failure (no pictures) 2017-11-09 15:40:49,537 INFO core: video output creation failed 2017-11-09 15:40:49,537 INFO core: failed to create video output 2017-11-09 15:40:49,539 INFO freetype: DirectWrite initialization failed. Falling back to GDI/Uniscribe 2017-11-09 15:40:49,544 INFO StaticVideoSetupCallback: Chroma=I420 Dim=1280x738 2017-11-09 15:40:49,544 INFO vmem: video format setup failure (no pictures) 2017-11-09 15:40:49,544 INFO core: video output creation failed 2017-11-09 15:40:49,545 INFO core: failed to create video output 2017-11-09 15:40:49,546 INFO freetype: DirectWrite initialization failed. Falling back to GDI/Uniscribe 2017-11-09 15:40:49,551 INFO StaticVideoSetupCallback: Chroma=I420 Dim=1280x738 2017-11-09 15:40:49,551 INFO vmem: video format setup failure (no pictures) 2017-11-09 15:40:49,551 INFO core: video output creation failed 2017-11-09 15:40:49,552 INFO core: failed to create video output 2017-11-09 15:40:49,552 INFO core: buffer deadlock prevented 2017-11-09 15:40:49,553 INFO freetype: DirectWrite initialization failed. Falling back to GDI/Uniscribe 2017-11-09 15:40:49,558 INFO StaticVideoSetupCallback: Chroma=I420 Dim=1280x738 2017-11-09 15:40:49,558 INFO vmem: video format setup failure (no pictures) 2017-11-09 15:40:49,558 INFO core: video output creation failed 2017-11-09 15:40:49,559 INFO core: failed to create video output 2017-11-09 15:40:49,559 INFO LibVLC event: Position Changed: 0.000000 2017-11-09 15:40:49,559 INFO LibVLC event: Position Changed: 0.000000StaticAudioPlayCallback: Count=1024, Timestamp=1971851702 2017-11-09 15:40:49,559 INFO StaticAudioPlayCallback: Count=1024, Timestamp=1971873035 ...... 2017-11-09 15:41:20,245 INFO StaticAudioPlayCallback: Count=1024, Timestamp=2003339703 2017-11-09 15:41:20,245 INFO StaticAudioPlayCallback: Count=1024, Timestamp=2003361036 2017-11-09 15:41:20,273 INFO StaticVideoLockCallback 2017-11-09 15:41:20,277 INFO StaticVideoDisplayCallback 2017-11-09 15:41:20,313 INFO StaticVideoLockCallback 2017-11-09 15:41:20,318 INFO StaticVideoDisplayCallback 2017-11-09 15:41:20,355 INFO StaticVideoLockCallback 2017-11-09 15:41:20,360 INFO StaticVideoDisplayCallback 2017-11-09 15:41:20,397 INFO StaticVideoLockCallback 2017-11-09 15:41:20,402 INFO StaticVideoDisplayCallback 2017-11-09 15:41:20,438 INFO StaticVideoLockCallback 2017-11-09 15:41:20,443 INFO StaticVideoDisplayCallback 2017-11-09 15:41:20,452 INFO LibVLC event: Position Changed: 0.283524

Seems vlc is living, but i can not figure out where the freeze happens

Arisego commented 7 years ago

I think i got some hint after print out more debug info, the video lock/display call back failed after first call. After first time LockCallback is called, it always fail on these conditions:

StaticVideoLockCallback(): Callbacks->VideoPreviousTime == Callbacks->CurrentTime StaticVideoDisplayCallback():(Callbacks == nullptr) || (VideoSample == nullptr)

Seems void FVlcMediaPlayer::TickInput(FTimespan DeltaTime, FTimespan /*Timecode*/) is not being called, maybe because the player is not valid if (Player.IsValid()) { Player->TickInput(DeltaTime, Timecode); } I am not familiar with the frame work system, and completely lost my way now...

Arisego commented 7 years ago

Some other information, I test this on my personal computer. When the game freezes in shipping mode, the audio is playing in the background, although I have not implement audio play out in my blueprint. Audios are also played in Development build and Standalone mode in Editor. But Play-In-Editor mode will not give any sound. I test the same video for the WMF player, all the mode wont give me sound. I guess there are some difference between each mode while using VLC.

Arisego commented 7 years ago

Seems RenderingThread is sucked in MediaTextureResource.cpp line 155:

        while (SampleSource->Peek(Sample) && Sample.IsValid())
        {
            const FTimespan StartTime = Sample->GetTime();
            const FTimespan EndTime = StartTime + Sample->GetDuration();

            if (((Params.Rate > 0.0f) && (StartTime > Params.Time)) ||
                ((Params.Rate < 0.0f) && (EndTime <= Params.Time)))
            {
                break; // future sample
            }

            SampleValid = SampleSource->Dequeue(Sample);
        }
Arisego commented 7 years ago

Finally I figure it out and make the video playing normally on shipping build. The problem happens on FMediaSamples::FetchVideo which has a queue pop logic in check() and will not compile on shipping build, so FMediaPlayerFacade::ProcessVideoSamples will always try to get new frame. See my pr for details:

47

gmpreussner commented 7 years ago

Hey Arisego, sorry you had to struggle through this - I just saw your message. The bug in UE4 4.18 was fixed in https://github.com/EpicGames/UnrealEngine/commit/2f1c3e2a2933acd351c5ca260342f7d05df7fae3 for 4.18.1