deus0ww / mpv-conf

55 stars 7 forks source link

Thumbnailer.lua crashes when toggling OSC in a freshly launched mpv #17

Closed dexeonify closed 2 years ago

dexeonify commented 2 years ago

Steps to reproduce

  1. Open any video file.
  2. Don't do anything else or move your cursor.
  3. Toggle Thumbnailer-toggle-osc using the keybind.
  4. Thumbnailer.lua crashes and the stack trace is shown in the console:
    stack traceback:
    [string "C:\Users\Blob\AppData\Roaming/mpv/scripts/Thu..."]:692: in function 'osc_set_visibility'
    [string "C:\Users\Blob\AppData\Roaming/mpv/scripts/Thu..."]:715: in function 'handler'
    mp.defaults:380: in function 'handler'
    mp.defaults:510: in function 'call_event_handlers'
    mp.defaults:552: in function 'dispatch_events'
    mp.defaults:503: in function <mp.defaults:502>
    [C]: at 0x7ff797fd32a0
    [C]: at 0x7ff797fd1520
    Lua error: [string "C:\Users\Blob\AppData\Roaming/mpv/scripts/Thu..."]:343: attempt to index upvalue 'state' (a nil value)

    This might not always be reproducible. If the OSC is shown at least once, then this error doesn't occur.

Workaround

My current workaround is to change these lines https://github.com/deus0ww/mpv-conf/blob/62fa158bbb4058c39564a26003aef1c18e10c32f/scripts/Thumbnailer.lua#L690-L693 to

local function osc_set_visibility(is_visible)
    if is_visible and not initialized then start(true)
    elseif osc_name then osc_update(nil, osc_set_options(is_visible), nil)
    else return end
end
deus0ww commented 2 years ago

I fixed this in a different way. Please test.

dexeonify commented 2 years ago

Yes, the fix works and it's more idiomatic. Thanks!