defold / extension-videoplayer-mpeg

Native extension to play back mpeg1 video using pl_mpeg
MIT License
3 stars 1 forks source link

VideoPlayer-MPEG crash on Play #1

Closed rezgi closed 2 months ago

rezgi commented 3 months ago

Is it a private platform, and a platform specific issue? (i.e. would it break your NDA?)
Then please report your issue in the corresponding extension repository!

Describe the bug (REQUIRED) When I launch the build of the VideoPlayer-MPEG example project, it plays the video for 2-3s then crashes every time. I didn't change anything in the example, I also tried with another video and I had the same problem. I tried with the other VideoPlayer extension and it works fine.

I get the following error :

INFO:DLIB: Log server started on port 50446
INFO:ENGINE: Target listening with name: Rezgi-Workstation - fe80::e8fd:9db0:e0b1:a729 - Windows
INFO:ENGINE: Engine service started on port 50447
INFO:GRAPHICS: Installed graphics device 'ADAPTER_FAMILY_OPENGL'
INFO:ENGINE: Defold Engine 1.9.1 (3be87d8)
INFO:DLIB: Initialized Remotery (ws://127.0.0.1:17815/rmt)
INFO:ENGINE: Loading data from: build/default
INFO:VIDEOPLAYERMPEG1: Registered mpeg Extension
INFO:ENGINE: Initialised sound device 'default'
INFO:VIDEOPLAYERMPEG1: Opened video with framerate: 24.000000, samplerate: 48000, duration: 53.708333
INFO:DLIB: SSDP: Started on address 192.168.100.107
INFO:CRASH: Successfully wrote Crashdump to file: C:\Users\Rezgi\AppData\Roaming\Defold/_crash
ERROR:CRASH: CALL STACK:

ERROR:CRASH:  0 0x7FF64DFA7510 dmCrash::GenerateCallstack D:\a\defold\defold\engine\crash\src\backtrace_win32.cpp:144
ERROR:CRASH:  1 0x7FF64E356E7C _seh_filter_exe /tmp/job11669631630059818958/minkernel/crts/ucrt/src/appcrt/misc/exception_filter.cpp:219
ERROR:CRASH:  2 0x7FF64E3AA958 `__scrt_common_main_seh'::`1'::filt$0 D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:304
ERROR:CRASH:  3 0x7FF64E315238 __C_specific_handler D:\a\_work\1\s\src\vctools\crt\vcruntime\src\eh\riscchandler.cpp:389
ERROR:CRASH:  4 0x7FFA84B342F0 __chkstk <unknown>:0
ERROR:CRASH:  5 0x7FFA84AAD9D0 RtlFindCharInUnicodeString <unknown>:0
ERROR:CRASH:  6 0x7FFA84B333E0 KiUserExceptionDispatcher <unknown>:0
ERROR:CRASH:  7 0x7FF64DF13770 plm_demux_decode /tmp/job11669631630059818958/upload/mpeg/src/pl_mpeg.h:2128
ERROR:CRASH:  8 0x7FF64DF11F40 plm_read_video_packet /tmp/job11669631630059818958/upload/mpeg/src/pl_mpeg.h:1217
ERROR:CRASH:  9 0x7FF64DF14CB0 plm_buffer_has_start_code /tmp/job11669631630059818958/upload/mpeg/src/pl_mpeg.h:1680
ERROR:CRASH: 10 0x7FF64DF132A0 plm_video_decode /tmp/job11669631630059818958/upload/mpeg/src/pl_mpeg.h:2809
ERROR:CRASH: 11 0x7FF64DF13110 plm_decode /tmp/job11669631630059818958/upload/mpeg/src/pl_mpeg.h:1133
ERROR:CRASH: 12 0x7FF64DF1EFF0 Decode /tmp/job11669631630059818958/upload/mpeg/src/mpeg.cpp:177
ERROR:CRASH: 13 0x7FF64DF210DE lj_BC_FUNCC <unknown>:0
ERROR:CRASH: 14 0x7FF64DF9E870 lua_pcall <unknown>:0
ERROR:CRASH: 15 0x7FF64DFCE310 dmScript::PCallInternal D:\a\defold\defold\engine\script\src\script.cpp:1401
ERROR:CRASH: 16 0x7FF64E036F20 dmGameObject::RunScript D:\a\defold\defold\engine\gameobject\src\gameobject\comp_script.cpp:144
ERROR:CRASH: 17 0x7FF64E037120 dmGameObject::CompScriptUpdateInternal D:\a\defold\defold\engine\gameobject\src\gameobject\comp_script.cpp:240
ERROR:CRASH: 18 0x7FF64E009970 dmGameObject::Update D:\a\defold\defold\engine\gameobject\src\gameobject\gameobject.cpp:2617
ERROR:CRASH: 19 0x7FF64E08F030 dmEngine::StepFrame D:\a\defold\defold\engine\engine\src\engine.cpp:1683
ERROR:CRASH: 20 0x7FF64E089EA0 dmEngineUpdate D:\a\defold\defold\engine\engine\src\engine.cpp:2218
ERROR:CRASH: 21 0x7FF64E08FAD0 dmEngine::RunLoop D:\a\defold\defold\engine\engine\src\engine_loop.cpp:83
ERROR:CRASH: 22 0x7FF64DF94C10 engine_main D:\a\defold\defold\engine\engine\src\engine_main.cpp:152
ERROR:CRASH: 23 0x7FF64E314DE4 __scrt_common_main_seh D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
ERROR:CRASH: 24 0x7FFA84482560 BaseThreadInitThunk <unknown>:0
ERROR:CRASH: 25 0x7FFA84AEAA30 RtlUserThreadStart <unknown>:0
ERROR:CRASH: Lua Callstack:
ERROR:CRASH:   example/player.script:36: in function <example/player.script:34>
ERROR:CRASH: 

INFO:CRASH: Successfully wrote Crashdump to file: C:\Users\Rezgi\AppData\Roaming\Defold/_crash
ERROR:CRASH: CALL STACK:

ERROR:CRASH:  0 0x7FF64DF13770 plm_demux_decode /tmp/job11669631630059818958/upload/mpeg/src/pl_mpeg.h:2128
ERROR:CRASH:  1 0x7FF64DF11F40 plm_read_video_packet /tmp/job11669631630059818958/upload/mpeg/src/pl_mpeg.h:1217
ERROR:CRASH:  2 0x7FF64DF14CB0 plm_buffer_has_start_code /tmp/job11669631630059818958/upload/mpeg/src/pl_mpeg.h:1680
ERROR:CRASH:  3 0x7FF64DF132A0 plm_video_decode /tmp/job11669631630059818958/upload/mpeg/src/pl_mpeg.h:2809
ERROR:CRASH:  4 0x7FF64DF13110 plm_decode /tmp/job11669631630059818958/upload/mpeg/src/pl_mpeg.h:1133
ERROR:CRASH:  5 0x7FF64DF1EFF0 Decode /tmp/job11669631630059818958/upload/mpeg/src/mpeg.cpp:177
ERROR:CRASH:  6 0x7FF64DF210DE lj_BC_FUNCC <unknown>:0
ERROR:CRASH:  7 0x7FF64DF9E870 lua_pcall <unknown>:0
ERROR:CRASH:  8 0x7FF64DFCE310 dmScript::PCallInternal D:\a\defold\defold\engine\script\src\script.cpp:1401
ERROR:CRASH:  9 0x7FF64E036F20 dmGameObject::RunScript D:\a\defold\defold\engine\gameobject\src\gameobject\comp_script.cpp:144
ERROR:CRASH: 10 0x7FF64E037120 dmGameObject::CompScriptUpdateInternal D:\a\defold\defold\engine\gameobject\src\gameobject\comp_script.cpp:240
ERROR:CRASH: 11 0x7FF64E009970 dmGameObject::Update D:\a\defold\defold\engine\gameobject\src\gameobject\gameobject.cpp:2617
ERROR:CRASH: 12 0x7FF64E08F030 dmEngine::StepFrame D:\a\defold\defold\engine\engine\src\engine.cpp:1683
ERROR:CRASH: 13 0x7FF64E089EA0 dmEngineUpdate D:\a\defold\defold\engine\engine\src\engine.cpp:2218
ERROR:CRASH: 14 0x7FF64E08FAD0 dmEngine::RunLoop D:\a\defold\defold\engine\engine\src\engine_loop.cpp:83
ERROR:CRASH: 15 0x7FF64DF94C10 engine_main D:\a\defold\defold\engine\engine\src\engine_main.cpp:152
ERROR:CRASH: 16 0x7FF64E314DE4 __scrt_common_main_seh D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
ERROR:CRASH: 17 0x7FFA84482560 BaseThreadInitThunk <unknown>:0
ERROR:CRASH: 18 0x7FFA84AEAA30 RtlUserThreadStart <unknown>:0
ERROR:CRASH: Lua Callstack:
ERROR:CRASH:   example/player.script:36: in function <example/player.script:34>
ERROR:CRASH: 

INFO:CRASH: Successfully wrote MiniDump to file: C:\Users\Rezgi\AppData\Roaming\Defold/_crash.dmp

To Reproduce (REQUIRED) Steps to reproduce the behavior:

  1. Get the VideoPlayer-MPEG example project from Github
  2. Build and launch
  3. Crash after 3s

Expected behavior (REQUIRED) The video should play without crashing.

Defold version (REQUIRED):

Platforms (REQUIRED):

Minimal repro case project (OPTIONAL): The project is on Github.

Logs (OPTIONAL): I attached the dump file. _crash.zip

Workaround (OPTIONAL): Didn't find one except use the other video player extension, which uses WebM instead of Mpeg.

AGulev commented 3 months ago

The issue moved from the Defold main issue tracker to the related extension repository.

rezgi commented 3 months ago

The issue moved from the Defold main issue tracker to the related extension repository.

Ok thanks. So next time I always need to report issues on the related extension right ?

britzl commented 3 months ago

The issue moved from the Defold main issue tracker to the related extension repository.

Ok thanks. So next time I always need to report issues on the related extension right ?

Yes, please!

rezgi commented 3 months ago

Noted. Sorry about that.

padreputativo commented 3 months ago

Same behavior in Ubuntu Linux, it crashes a few seconds into playing the video. Screenshot from 2024-07-30 16-43-37

padreputativo commented 3 months ago

Apparently, if you press Stop and then hit Play, the crash is fixed.

rezgi commented 3 months ago

Apparently, if you press Stop and then hit Play, the crash is fixed.

I did that too before and it worked a few more seconds before it crashed again.

padreputativo commented 3 months ago

changing this, works for me Screenshot from 2024-07-30 17-55-50

padreputativo commented 3 months ago

It doesn't fix the issue for all videos. It continues to crash.

rezgi commented 3 months ago

Interesting to note :

padreputativo commented 2 months ago

My knowledge of C is very basic, but I’ve been looking at the implementation, and it doesn’t seem to have anything unusual. So I thought the problem might be with Lua, in the demo script itself. I removed the comment from the stream function and commented out the call to the play function that appears in init, and it no longer crashes (although it shows visual errors).

padreputativo commented 2 months ago

I have tried to clean up Lua's garbage collector, but it keeps crashing, so I suppose the issue is in the open function in C++.

AGulev commented 2 months ago

Are you sure you are using the same exact example as in the original repository? I've just downloaded it and watched the video 5 times - it just works.

padreputativo commented 2 months ago

Yes, even with the untouched repository, it crashes after a few seconds. If I stop and play again, sometimes it works, but it depends on the video. Maybe it has more problems with higher resolution videos. It must be some kind of buffer issue because it doesn't seem to happen with the stream function (although, as I said, maybe it happens with higher resolution videos). I don't know if it's something that only happens on Linux.

padreputativo commented 2 months ago

I think I've found the problem. I'm attaching a video. I believe that the open operation from Lua is causing the garbage collector to kill the buffer before it is loaded into memory by the C script. So, by declaring the variable as a local variable in the script instead of as a local variable in the method, it stays in memory longer, giving it time to load. This might only happen with disks or memory of certain speeds.

https://github.com/user-attachments/assets/192367b0-ec79-4371-9175-7f1b46a8b99f

britzl commented 2 months ago

Ah, yeah, the result from resource.load() will return a buffer and that might ofc be garbage collected. We don't want the videoplayer to have to copy the video data so you need to keep that reference around while playing the video. I have updated the example so that it does this too.