LittlePictureFrames

LittlePictureFrames

751k Downloads

Lagspikes when start to play a new video

SrRapero720 opened this issue ยท 8 comments

commented

This is caused by VLC. trying to load media on the render thread
this can be fixed creating a new thread for this line

Someting like this

var thread = new Thread(() -> player.mediaPlayer().media().start(url));
thread.setName("LF/Play");
thread.setDaemon(true);
thread.start();
commented

Only is required on play method
other methods only set vars but no start to process media. just to prevent more bugs

commented

Thanks a lot for your suggestion. Sorry for not responding earlier. Added it in the newest version. Not sure if the lag spike will be gone now, we shall see.

commented

I did not notice any difference in the lag spike to be honest. That's why I thought more would be better. At least on my system it did not change anything.

commented

Is pretty notable

BEFORE:

2023-04-28.02-57-42.mp4

AFTER:

2023-04-28.03-03-16.mp4

commented

Nice, maybe it's because I only played an audio file with vlc. Thanks again for your help! Very good job! (Will do the change, but wait to release once there is something else has changed as well).

EDIT:
Actually can you try out if there is a difference if all is threaded and just the start call? I will upload a new version. Would be cool if you could test it.

commented

https://www.dropbox.com/s/fmc92kda8xvreih/LittleFrames_FORGE_v1.1.16_mc1.19.4.jar?dl=1

This version only threads the start call. Maybe it's more laggy than threading everthing?

commented

i made that test in a backported version of LF. keeps the same performance
https://github.com/SrRapero720/WATERFrAMES

Btw the main reason of why i only suggest to thread the start call is by this:
Crash: https://gist.github.com/SrRapero720/998e317ebbfb9b752432c035f0553025
Build with the gist crash: https://www.curseforge.com/minecraft/mc-mods/littleframes/files/4508008

threading everything causes crashes with placed frames, rejoining a server or singleplayer world with video-frames and sometimes placing new frames in fresh worlds. And no reduces more lag (that threaded start call can do)
Using the 1.1.16 build haven't that crash

commented

Ok, thanks a lot for testing it out! Uploaded 1.1.16 to curseforge and modrinth. Cannot thank you enough for all your effort!