Skip to content

Commit

Permalink
Fix mjpg stream accumulation (#1293)
Browse files Browse the repository at this point in the history
Fixes bug where switching tabs/etc causes buildup of connected mjpg streams in network, eventually slowing down streams and causing stream failure until refresh. Accomplishes this by directly setting the source of stream elements to null before unmount, allowing chrome/edge to close the connection.

Fixes #1106
  • Loading branch information
DevonRD authored Mar 21, 2024
1 parent c89acea commit 97d2050
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions photon-client/src/components/app/photon-camera-stream.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { computed, inject } from "vue";
import { computed, inject, ref, onBeforeUnmount } from "vue";
import { useCameraSettingsStore } from "@/stores/settings/CameraSettingsStore";
import { useStateStore } from "@/stores/StateStore";
import loadingImage from "@/assets/images/loading.svg";
Expand Down Expand Up @@ -53,11 +53,17 @@ const handleFullscreenRequest = () => {
if (!stream) return;
stream.requestFullscreen();
};
const mjpgStream: any = ref(null);
onBeforeUnmount(() => {
if (!mjpgStream.value) return;
mjpgStream.value["src"] = null;
});
</script>

<template>
<div class="stream-container">
<img :id="id" crossorigin="anonymous" :src="streamSrc" :alt="streamDesc" :style="streamStyle" />
<img :id="id" crossorigin="anonymous" :src="streamSrc" :alt="streamDesc" :style="streamStyle" ref="mjpgStream" />
<div class="stream-overlay" :style="overlayStyle">
<pv-icon
icon-name="mdi-camera-image"
Expand Down

0 comments on commit 97d2050

Please sign in to comment.