> Source/WebCore/ChangeLog:13
> + Files cached on disk by MediaPlayerPrivateGStreamer are deleted only when the player is closed. If the
> + WebProcess crashed, they're just left there in the cache directory. This patch changes the location
> + of those temporary files to a proper temporary directory (/var/tmp, as those files aren't actually
> + reusable, so they don't belong to a cache directory, and /tmp is a bad place because it's RAM-based on
> + some distros), unlinks (deletes) them right after creation and also deletes any other stalled temporary
> + file on the old legacy cache directory.
Wouldn't it be a problem if /var is in a different partition? I'm not sure if the solution to leaked files is placing them in /tmp to be honest. If we can decide the folder, then we can use a specific one in the user cache dir, and clean it up at startup, for example.
> Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:1348
> + if (!g_strcmp0(className, "GstDownloadBuffer")) {
Comment on attachment 300331
Patch
View in context: https:/ /bugs.webkit. org/attachment. cgi?id= 300331& action= review
> Source/ WebCore/ ChangeLog: 13 ateGStreamer are deleted only when the player is closed. If the
> + Files cached on disk by MediaPlayerPriv
> + WebProcess crashed, they're just left there in the cache directory. This patch changes the location
> + of those temporary files to a proper temporary directory (/var/tmp, as those files aren't actually
> + reusable, so they don't belong to a cache directory, and /tmp is a bad place because it's RAM-based on
> + some distros), unlinks (deletes) them right after creation and also deletes any other stalled temporary
> + file on the old legacy cache directory.
Wouldn't it be a problem if /var is in a different partition? I'm not sure if the solution to leaked files is placing them in /tmp to be honest. If we can decide the folder, then we can use a specific one in the user cache dir, and clean it up at startup, for example.
> Source/ WebCore/ platform/ graphics/ gstreamer/ MediaPlayerPriv ateGStreamer. cpp:1348 className, "GstDownloadBuf fer")) {
> + if (!g_strcmp0(
Early return here instead.
> Source/ WebCore/ platform/ graphics/ gstreamer/ MediaPlayerPriv ateGStreamer. cpp:1350 handlers_ disconnect_ by_func( bin, gpointer( uriDecodeBinEle mentAddedCallba ck), player);
> + g_signal_
Use C++ style casts
> Source/ WebCore/ platform/ graphics/ gstreamer/ MediaPlayerPriv ateGStreamer. cpp:1358
> + processName = "GStreamer";
shouldn't it be WebKitWebProcess by default?
> Source/ WebCore/ platform/ graphics/ gstreamer/ MediaPlayerPriv ateGStreamer. cpp:1360 late(g_ strdup_ printf( "/var/tmp/ %s-XXXXXX" , processName));
> + GUniquePtr<gchar> newDownloadTemp
Use g_build_filename
> Source/ WebCore/ platform/ graphics/ gstreamer/ MediaPlayerPriv ateGStreamer. cpp:1364 >purgeOldDownlo adFiles( oldDownloadTemp late.get( ));
> + player-
So, if we purge the old files, then we don't really need to use /var/tmp, no?
> Source/ WebCore/ platform/ graphics/ gstreamer/ MediaPlayerPriv ateGStreamer. cpp:1372 handlers_ disconnect_ by_func( player- >m_downloadBuff er.get( ), gpointer( downloadBufferF ileCreatedCallb ack), player);
> + g_signal_
Use C++ style cast
> Source/ WebCore/ platform/ graphics/ gstreamer/ MediaPlayerPriv ateGStreamer. cpp:1379 gchar> downloadFile; get(player- >m_downloadBuff er.get( ), "temp-location", &downloadFile. outPtr( ), nullptr); downloadFile. get()) == -1) "Couldn' t unlink media temporary file %s after creation", downloadFile. get()); get());
> + GUniqueOutPtr<
> + g_object_
> + if (g_unlink(
> + GST_WARNING(
> + else
> + GST_TRACE("Unlinked media temporary file %s after creation", downloadFile.
Do we need a signal for this? Doesn't gst changes it when g_object_ set(element, "temp-template", synchronously?
> Source/ WebCore/ platform/ graphics/ gstreamer/ MediaPlayerPriv ateGStreamer. cpp:1411 templatePath. get(), 0, nullptr); name(directory) ; fileName; fileName = g_dir_read_ name(directory) ) { has_prefix( fileName, templateFile. get())) { g_build_ filename( templatePath. get(), fileName, nullptr)); filePath. get()) == -1) "Couldn' t unlink legacy media temporary file: %s", filePath.get());
> + GDir* directory = g_dir_open(
> +
> + if (!directory)
> + return;
> +
> + for (const gchar* fileName = g_dir_read_
> + if (g_str_
> + GUniquePtr<gchar> filePath(
> + if (g_unlink(
> + GST_WARNING(
> + else
> + GST_TRACE("Unlinked legacy media temporary file: %s", filePath.get());
> + }
> + }
You can simplify this by using FileSystem: :listDirectory( ), you can pass a regexp to mathc the files directly
> Source/ WebCore/ platform/ graphics/ gstreamer/ MediaPlayerPriv ateGStreamer. cpp:1418
> m_source.clear();
You should disconnect previous signals here and in the destructor I guess, since you are disconnecting only if the signals was emitted.
> Source/ WebCore/ platform/ graphics/ gstreamer/ MediaPlayerPriv ateGStreamer. h:249
> + GRefPtr<GstElement> m_downloadBuffer;
Do we really want to keepo this buffer object alive for the whole life of the media platyer? Or can we release it at some point?