Blank screen upon video player's exit

Often when I close video player (exit a video stream), the screen becomes black, and stays this way for 5-10 seconds and only then UI appears. It doesn’t happen each time, but fairly often (in about 30% of the cases). An option ‘Adjust display refresh rate’ is turned off.

How it can be solved?

I am using version 19.4, on Vontar x3 (amlogic s905x3).

Here is a relevant part from the log (note the 10 seconds jump in time):

2022-04-13 20:50:14.019 T:3779     INFO <general>: Skipped 1 duplicate messages..
2022-04-13 20:50:14.019 T:3779     INFO <general>: CVideoPlayer::CloseFile()
2022-04-13 20:50:14.019 T:3779     INFO <general>: VideoPlayer: waiting for threads to exit
2022-04-13 20:50:14.027 T:4619     INFO <general>: CVideoPlayer::OnExit()
2022-04-13 20:50:14.027 T:4619     INFO <general>: Closing stream player 1
2022-04-13 20:50:14.028 T:4619     INFO <general>: Waiting for audio thread to exit
2022-04-13 20:50:14.067 T:4630     INFO <general>: thread end: CVideoPlayerAudio::OnExit()
2022-04-13 20:50:14.068 T:4619     INFO <general>: Closing audio device
2022-04-13 20:50:14.119 T:3786     INFO <general>: CActiveAESink::OpenSink - initialize sink
2022-04-13 20:50:14.119 T:4619     INFO <general>: Deleting audio codec
2022-04-13 20:50:14.120 T:4619     INFO <general>: Closing stream player 2
2022-04-13 20:50:14.120 T:4619     INFO <general>: waiting for video thread to exit
2022-04-13 20:50:14.169 T:4629  WARNING <general>: OutputPicture - timeout waiting for buffer
2022-04-13 20:50:14.169 T:4629     INFO <general>: thread end: video_thread
2022-04-13 20:50:14.172 T:4619     INFO <general>: deleting video codec
2022-04-13 20:50:14.318 T:3786     INFO <general>: CAESinkALSA::Initialize - Configure simple control for "AUGESOUND"
2022-04-13 20:50:14.318 T:3786     INFO <general>: CAESinkALSA - Use card "hw:0" and set codec format "2 CH PCM"
2022-04-13 20:50:14.320 T:3786     INFO <general>: CAESinkALSA - Set codec for "Audio spdif format"
2022-04-13 20:50:14.320 T:3786     INFO <general>: CAESinkALSA - Set codec for "Audio spdif_b format"
2022-04-13 20:50:14.320 T:3786     INFO <general>: CAESinkALSA - Set Spdif to HDMITX to "Spdif"
2022-04-13 20:50:14.320 T:3786     INFO <general>: CAESinkALSA::Initialize - Attempting to open device "surround71:CARD=AMLAUGESOUND,DEV=0"
2022-04-13 20:50:14.327 T:3786     INFO <general>: CAESinkALSA::Initialize - Opened device "surround71:CARD=AMLAUGESOUND,DEV=0"
2022-04-13 20:50:14.329 T:3786     INFO <general>: CAESinkALSA::InitializeHW - Your hardware does not support AE_FMT_FLOAT, trying other formats
2022-04-13 20:50:14.329 T:3786     INFO <general>: CAESinkALSA::InitializeHW - Using data format AE_FMT_S24NE4
2022-04-13 20:50:24.234 T:4619     INFO <general>: ADDON: Dll Destroyed - Inputstream FFmpeg Direct
2022-04-13 20:50:24.235 T:3779     INFO <general>: VideoPlayer: finished waiting
2022-04-13 20:50:24.235 T:3779     INFO <general>: CVideoPlayer::CloseFile()
2022-04-13 20:50:24.235 T:3779     INFO <general>: VideoPlayer: waiting for threads to exit
2022-04-13 20:50:24.235 T:3779     INFO <general>: VideoPlayer: finished waiting

Relevant is only full debug log.

Here is a full log: http://ix.io/3V3t

The problem reproduced on a 3rd try (the jump in time is in the end of the log, between 21:27:57.028 and 21:28:04.805).

It should be the resolution change, GUI is most in 1080p 50 or 60hz. When you watch a media with 4k or 24hz the TV will change resolution to have best matching. When stop playback it switch back to GUI resolution. So best is to match GUI resolution for the most used media resolution.

It doesn’t seem to be the cause - the channel I was trying to watch has a fixed resolution (540p), and most times the problem didn’t occur, while the other times it did occur - and all this on a single channel. If the problem is in resolution change, then the problem either shouldn’t have occurred at all, or should have occurred each time. In addition, this problem never occurred on a legacy CE version (19.2.4.2 - on an older device, but on the same TV set) even though the legacy version had the same GUI resolution.

I have found causes of the problem, but still don’t have a solution. First, I should have mentioned that the problem occurs when I use PVR Simple Client (this is the only way I played videos until now).

The problem is in addons inputstream.ffmpegdirect & pvr simple client: the black screen after video player is closed is caused by inputstream.ffmpegdirect - seems that it is stuck cleaning timeshift buffers or something like that, and this prevents video player from finalizing itself and returning to the UI. When timeshift is disabled in PVR simple client, this problem doesn’t happen, that is: when video is closed, there is no blank screen - UI immediately appears. But - having timeshift disabled causes significant delay when video is started - it takes 10-30 seconds for a video to start playing after it is started. This happens because when timeshift is disabled, PVR simple client fetches & parses both the playlist & EPG every time the video is started - it doesn’t use cache. And it doesn’t start a video until after all this processing is complete. So if you have a large playlist and EPG, this processing takes a lot of time.

So it is a lose-lose situation - you either get a huge delay upon video start, or a huge delay upon video stop.

Is it possible to fix those problems (preferably both of them)?

Note: none of the things described above happen on a x64 Kodi (using 19.4 on Archlinux), therefore it seems plausible that this is somehow related to CE-specific patches (archlinux uses upstream’s package as is, except for one very small build time configuration SSE-related patch).