Skip to content

bugfix: ensure live preview is not cached#1267

Merged
andi34 merged 2 commits intoPhotoboothProject:devfrom
nbosb:dev-preview
Oct 28, 2025
Merged

bugfix: ensure live preview is not cached#1267
andi34 merged 2 commits intoPhotoboothProject:devfrom
nbosb:dev-preview

Conversation

@nbosb
Copy link
Copy Markdown
Contributor

@nbosb nbosb commented Oct 26, 2025

I use a setup with a live preview showing an MJPEG-based stream created by Go2rtc during the countdown. When using an iPad to control the photobooth, the preview works fine when taking a picture. However, when I click the newPhoto button on the results page, only the last frame of the previous live stream is shown. Everything works fine when I use Firefox on Windows. I think this is exactly the same issue as described in #942.
It seems that Safari (iOS 17.7.10) and Chrome (141.0.7390.41) on the iPad cache the last frame when the preview--ipcam element is hidden, and only use this frame when it is shown again instead of fetching the stream.

Prerequisites checklist

What is the purpose of this pull request? (put an "x" next to an item)

  • Documentation update
  • Bug fix
  • New feature
  • Other, please explain:

What changes did you make? (Give an overview)

It seems that caching cannot be disabled for background images applied to div elements.
As a workaround, I added a cache-busting query parameter to the stream URL so that it’s unique each time the preview--ipcam element is shown.

To simplify handling the stream source, I changed the preview--ipcam element from a div with a CSS background image to an <img> element. This allows the stream URL to be passed directly via the src attribute instead of using url('...').
A timestamp (t=<timestamp>) is appended to the URL to ensure it’s different each time and therefore not cached by the browser.

Tested on
  • Firefox 143.0.4 (Windows)
  • Safari (iOS 17.7.10)
  • Chrome 141.0.7390.41 (iOS 17.7.10)
  • Chrome 141.0.7390.122 (Android 15)
Note

The stream URL must now be passed directly to the <img> element; the url('...') syntax is no longer needed.

Is there anything you'd like reviewers to focus on?

As I’m not a JS/PHP developer, I’d appreciate it if you could check whether I’ve missed any best practices or made any mistakes in the implementation. Please feel free to point out any issues with the code, especially if something seems unconventional or my implementation causes problems I am not aware of.

@andi34
Copy link
Copy Markdown
Contributor

andi34 commented Oct 27, 2025

Hey and thanks for your pull request!
I've not tested yet, but looks good to me. The following files need to be adjusted too:

  • admin/captureconfig.php
  • admin/wgetcaptureconfig.php

Could you please adjust the config entries there too?

@nbosb
Copy link
Copy Markdown
Contributor Author

nbosb commented Oct 27, 2025

Hi, thanks for the hint. I have updated the files, too.

@andi34
Copy link
Copy Markdown
Contributor

andi34 commented Oct 28, 2025

Thanks for the update. I am now thinking about how to handle already configured Photobooth to not break. Any ideas?

nbosb added 2 commits October 28, 2025 20:14
On some devices, the video preview freezes when the video is hidden and
then shown again (e.g, show preview during countdown; hide preview to
show taken picture; show preview during countdown of the next picture).
This is because the last frame can be cached by the browser when the
preview is hidden, and this cached frame is displayed when the preview
is shown again.
To disable caching, a unique parameter is added to the URL of the
stream of the stream.

Signed-off-by: Nils Bosbach <n.bosbach@gmx.de>
When the config has been created by a previous version, the preview.url
field may contain values wrapped in `url("...")`. The updated version no
longer requires this wrapper. If the preview.url field starts with `url(`
and ends with `)`, the `url(...)` wrapper and any surrounding quotes are
removed.

Signed-off-by: Nils Bosbach <n.bosbach@gmx.de>
Comment thread src/Service/ConfigurationService.php
@andi34 andi34 merged commit 11987ca into PhotoboothProject:dev Oct 28, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants