From fb1265c5cf24462985cd3debae9205ac78f5d6ab Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 22 Mar 2021 16:24:03 +0100 Subject: Tracking: Fix movie file prefetch freezing interface The issue was caused by the prefetch code having LOCK_MOVIECLIP lock acquired while reading frames from the movie files. The need of the lock was coming from the fact that `clip->anim` can not be accessed from multiple threads, so that was guarded by a lock. The side effect of this lock was that the main thread (from which drawing is happening) did not have any chance passing through it in the cache code because the prefetch happens so quickly. The solution is to create a local copy of the clip with its own anim handler, so that read can happen without such lock. The prefetch is slower by an absolute number in seconds (within 10% in tests here), but it is interactive now. --- source/blender/blenkernel/intern/movieclip.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index 017a73593ee..9c2cd03dbc2 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -1958,14 +1958,12 @@ void BKE_movieclip_filename_for_frame(MovieClip *clip, MovieClipUser *user, char } } -ImBuf *BKE_movieclip_anim_ibuf_for_frame(MovieClip *clip, MovieClipUser *user) +ImBuf *BKE_movieclip_anim_ibuf_for_frame_no_lock(MovieClip *clip, MovieClipUser *user) { ImBuf *ibuf = NULL; if (clip->source == MCLIP_SRC_MOVIE) { - BLI_thread_lock(LOCK_MOVIECLIP); ibuf = movieclip_load_movie_file(clip, user, user->framenr, clip->flag); - BLI_thread_unlock(LOCK_MOVIECLIP); } return ibuf; -- cgit v1.2.3