Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve responsiveness when opening many files #827

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Dec 6, 2022

  1. Reduce playlist widget view updates

    This commit improves performance when opening or enqueuing
    many (150+) files at once.
    
    Celluloid was unresponsive when it attempted to
    open many files at once, either as command line
    arguments or through the --enqueue option. Additionally,
    the timestamp/scrubber repeatedly jumped between the current
    video position and 0:00 many times
    (until the metadata cache update handler had run for each
    video in the playlist).
    
    This is due to too many view updates on the playlist widget.
    Calling the playlist handler is a heavy operation that
    updates the contents of the playlist widget, clearing
    the current playlist model and building another one
    based off the (up-to-date) internal playlist, which takes O(n) time.
    I expected that the playlist widget should get updated once per
    batch file open, but in fact the playlist view was getting
    regenerated like this at least two times per enqueued file,
    so processing an opened playlist was O(n^2).
    
    The first piece calling playlist updates is the
    metadata cache update handler
    (metadata_cache_update_handler in celluloid-controller.c).
    This handler is run for each new opened file which includes a
    playlist view update. By running the playlist view update only once
    at the end of the playlist we get a dramatic speedup, and the
    timestamp no longer erratically skips between 0:00 and the current time.
    
    The second piece responsible is load_file (celluloid-player.c).
    For each loaded file, the old behavior was to notify the playlist
    update handler (g_object_notify) if idle. However, the result
    appeared to be that when enqueuing many files into an idle
    Celluloid instance, the playlist update handler was called for each,
    which caused a large slowdown when enqueuing many files.
    We can instead defer the playlist update to mpv_property_changed
    which appears to be just as functional.
    estorok committed Dec 6, 2022
    Configuration menu
    Copy the full SHA
    4574c24 View commit details
    Browse the repository at this point in the history