I’m seeing a bug in my video player where after creating a bunch of
video objects, opening any subsequent files will result in a
file x not found: Too many open files error.
I find that this happens exactly after the 64th video opened. The problem is that in my case, I open videos multiple times throughout the app’s life. And it looks like these accumulate and never actually close the file.
Am I understanding this correctly? If so, how does one close a
video object? (I tried setting it to
nil but it makes no difference.)
Here’s a basic program that recreates this bug. (Create an
Assets folder with at least 64
pdv files in it. You can get a sample
pdv file here and duplicate it as many times as needed.)
import "CoreLibs/graphics" -- List files within a folder that contains at least 64 videos. local folder = "Assets/" local files = playdate.file.listFiles(folder) for _, path in ipairs(files) do local video, videoerr = playdate.graphics.video.new(folder .. path) print(path, video, videoerr) end -- Any other file open after that will result in a “Too many files open” error. local img, imgerr = playdate.graphics.image.new("SystemAssets/card") print(img, imgerr) local info, infoerr = playdate.file.open("pdxinfo") print(info, infoerr) function playdate.update() end