Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetch image before spawning viewer #1

Closed
wants to merge 1 commit into from
Closed

Conversation

stuartpb
Copy link
Owner

@stuartpb stuartpb commented Oct 18, 2021

What this patch does

In the existing code, the URL received in the /present/still request is passed directly to feh, which then handles all the work of requesting the image from the webcam over HTTP.

This PR makes it so the Node process requests the image, then pipes that image into feh over stdin.

Upsides of this patch

In testing, the image was presented about a quarter of a second faster after sending the presentation request (although the actual latency before fetching the image was unaffected), and the previous instance of feh was preserved for another quarter-second longer (leading to something like an overall reduction of a half a second of blank screen time, when presenting multiple stills).

Note that this patch did not appear to have a noticeable impact on the latency of the requested image itself: while I didn't specifically test image request latency, the loaded image's on-screen timestamp always matched the date of the request to the second regardless of implementation. This performance boost is only a presentation detail.

Downsides to this patch

Requesting the image necessitates the introduction of node-fetch to do cleanly, which entails its own further dependencies in turn (see the changes to the lockfile), and has an uncertain maintenance future due to turmoil in the ecosystem. Further updates to this dependency are likely to introduce friction with the minimum supported Node runtime version, which is already a pain to manage on Raspbian. (Ideally, this fetch functionality would be part of Node's core, but that's in the air at the moment, too.)

herald/package.json Outdated Show resolved Hide resolved
@stuartpb
Copy link
Owner Author

re: introducing node-fetch as a dependency to herald: it's already a dependency of sentinel, so it's not that big a deal. That being said, we can switch to another fetch implementation like minipass-fetch (for both sides) if we want to keep clean Node 10 support (or we can figure out a support path for newer versions of Node, which will likely be the easier option at some point in the future, although it isn't today).

@stuartpb
Copy link
Owner Author

stuartpb commented Mar 6, 2024

Native fetch landed in Node.js 18 (the Pis are currently set up for Node 20, but I'm updating them to 21, where it officially became stable, now). I'm going to bump engines in both ends, and then I might rebase and pull this change in.

stuartpb added a commit that referenced this pull request Mar 6, 2024
stuartpb added a commit that referenced this pull request Mar 6, 2024
@stuartpb stuartpb closed this in #4 Mar 6, 2024
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.

None yet

2 participants