Skip to content

Non-blocking PreviewJob

Bharadwaj Raju requested to merge work/bharadwaj/previewjob-async into master

Make mimetype lookup async using a StatJob. Thus PreviewJob no longer blocks on determining mimetype, as often happens on slow filesystems.

Test Plan

Test non-blocking-ness

Since Dolphin has other factors which cause the UI to block on slow filesystems, I suggest using KIO previewtest to test this change in isolation.

Either use a slow network filesystem, or simulate one like this:

# Create a device with an artificial delay of 3 seconds for all read operations
dd if=/dev/zero of=/tmp/10M-of-zeroes bs=1024k count=10
loopdev=$(sudo losetup --show --find /tmp/10M-of-zeroes)
devsize=$(sudo blockdev --getsize "$loopdev")
# This will probably take a while to finish
echo "0 $devsize delay $loopdev 0 3000 $loopdev 0 0" | sudo dmsetup create dm-slow
sudo mkfs.ext4 /dev/mapper/dm-slow
sudo mkdir -p /mnt/slow
sudo mount /dev/mapper/dm-slow /mnt/slow
sudo chmod a+rwx /mnt/slow

Then copy something like a JPEG to /mnt/slow.

Note: Before each test, tell the kernel to drop disk cache with sudo sh -c 'echo 3 > /proc/sys/vm/drop_caches' and remove ~/.cache/thumbnails.

Then, enter the path to the slow file into previewtest and click Generate. Move your mouse over various UI elements.

With this patch, the UI will not block.

Test existing real users of PreviewJob

Use Dolphin and the file picker as usual, ensure there are no crashes or new slowdowns.

Edited by Bharadwaj Raju

Merge request reports

Loading