FFmpegInterop.dll registers a custom FFmpeg logging callback, FmpegInteropLogging::Log(), on DLL load. However, this is not safe to do in scenarios that have multiple DLLs using FFmpeg due to the following race condition:
FFmpegInterop.dll is loaded and registers its custom FFmpeg logging callback, FmpegInteropLogging::Log().
OtherModule.dll, which also uses FFmpeg, is also loaded in the same process.
FFmpegInterop.dll is unloaded and av_log_callback becomes a dangling pointer.
OtherModule.dll is still loaded and using FFmpeg. FFmpeg attempts to invoke the now invalid logging callback, resulting in undefined behavior.
Even if the default logging callback was restored on DLL unload, since there is no thread safety in the FFmpeg logging facility, log_callback in av_vlog() could become a dangling pointer.
What changed?
Disabled FFmpeg logging in release builds. Debug builds still register the custom logging callback on DLL load, but now also restore the default logging callback on DLL unload (which isn't thread safe and could still result in a crash).
How was the change tested?
For Ogg playback in Media Player with in-proc WME, I verified under a debugger that:
For release builds:
FFmpeg logging is disabled during DLL load.
For debug builds:
The custom logging callback is registered/unregistered during DLL load/unload.
FFmpeg logging is present in ETW traces collected with WPR.
Why is this change being made?
FFmpegInterop.dll registers a custom FFmpeg logging callback, FmpegInteropLogging::Log(), on DLL load. However, this is not safe to do in scenarios that have multiple DLLs using FFmpeg due to the following race condition:
Even if the default logging callback was restored on DLL unload, since there is no thread safety in the FFmpeg logging facility, log_callback in av_vlog() could become a dangling pointer.
What changed?
Disabled FFmpeg logging in release builds. Debug builds still register the custom logging callback on DLL load, but now also restore the default logging callback on DLL unload (which isn't thread safe and could still result in a crash).
How was the change tested?
For Ogg playback in Media Player with in-proc WME, I verified under a debugger that: