Closed richiemcilroy closed 4 weeks ago
/bounty $25
/attempt #25
with your implementation plan/claim #25
in the PR body to claim the bountyThank you for contributing to CapSoftware/Cap!
Add a bounty • Share on socials
Attempt | Started (GMT+0) | Solution |
---|---|---|
🔴 @feliciien | Apr 12, 2024, 6:21:11 PM | WIP |
🔴 @Anshgrover23 | Jun 27, 2024, 3:29:57 PM | WIP |
/attempt #25
Algora profile | Completed bounties | Tech | Active attempts | Options |
---|---|---|---|---|
@feliciien | 5 bounties from 1 project | MDX, Rust, JavaScript & more |
Cancel attempt |
Hey @feliciien are you working on this?
yes
Le sam. 13 avr. 2024 à 12:30, Richie McIlroy @.***> a écrit :
Hey @feliciien https://github.com/feliciien are you working on this?
— Reply to this email directly, view it on GitHub https://github.com/CapSoftware/Cap/issues/25#issuecomment-2053633395, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3Y7KB5SREEATMZLJBTOSTLY5EQPLAVCNFSM6AAAAABGCIOVTWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANJTGYZTGMZZGU . You are receiving this because you were mentioned.Message ID: @.***>
/attempt #25
/bounty $100
Upped the bounty here, would love to get this one fixed
Giving it a try @richiemcilroy
awesome, thank you @Vijaykv5!
You can refer to this section here in the contributing guide:
Here are some steps and pointers to help you get started on resolving this issue:
Reproduce the Issue:
Investigate Initialization Logic:
Camera.tsx
component. Specifically, the useEffect
hook that initializes the camera might not handle the app being in the background properly.Modify Initialization Logic:
document.hidden
property to check if the app is in the background.Handle App Visibility Changes:
visibilitychange
event to handle cases where the app moves from the background to the foreground. Reinitialize the camera if necessary.Camera Component: The main logic for the camera overlay is in the Camera.tsx
file.
/apps/desktop/src/components/windows/Camera.tsx
Key section to modify:
useEffect(() => {
if (!videoRef.current || !selectedVideoDevice) return;
const video = videoRef.current;
const constraints = {
video: {
deviceId: selectedVideoDevice.id,
},
};
if (typeof navigator === "undefined") return;
const initializeCamera = () => {
navigator.mediaDevices
.getUserMedia(constraints)
.then((stream) => {
video.srcObject = stream;
video.play();
setIsLoading(false);
})
.catch((err) => {
console.error(err);
});
};
if (!document.hidden) {
initializeCamera();
}
const handleVisibilityChange = () => {
if (!document.hidden) {
initializeCamera();
}
};
document.addEventListener("visibilitychange", handleVisibilityChange);
return () => {
document.removeEventListener("visibilitychange", handleVisibilityChange);
if (video.srcObject) {
const stream = video.srcObject as MediaStream;
stream.getTracks().forEach((track) => {
track.stop();
});
}
};
}, [selectedVideoDevice]);
App Initialization: Ensure the app's main page handles the camera window state correctly.
/apps/desktop/src/app/page.tsx
Is the previous message automated?
I cannot reproduce the issue even when I set the app to be unfocused and minimized on start. It happens at random when I change the input video quickly between 3 devices.
Also, I keep getting the update available message even though my fork is synced with the main branch. (Apparently release is newer than main for now.)
~~Hey @richiemcilroy! Could you please try out this branch and check if it's solved the issue? If not I'd greatly appreciate it if you could provide a little more info on how to reproduce this.~~
Also, I came across a few other issues trying this. It seems like switching between cameras doesn't work properly and it gets stuck on the same input the app started with (Same commit, and the latest release).
All Tao windows come into focus by default unless specified. The camera overlay is set to always be on top. After forcing them to go behind everything, the video gets hidden and then starts playing again once the window is visible and this is without any changes required it seems. Has anyone else reported this same issue?
If the provided fix works, then I'm going to cleanup and re-do some parts of Camera.tsx
and MediaDeviceContext.tsx
(And probably a few more…)
Hey @ItsEeleeya I'm currently working on fixing them and would raise a PR soon
Hey @ItsEeleeya I'm currently working on fixing them and would raise a PR soon
Awesome! It'd be great if you could also fix the device changing issue
its time to go back working on the tauri v2 transition for me 👀
hey @ItsEeleeya - you want to create your branch as a PR so I can take a look?
Can we close this issue @richiemcilroy if its fixed!
Issue It's possible to break the camera window (window turns black) when the app is first launched. Seems to happen if the app has launched in the background, then you open it after the camera preview has already initialised.
You can use this guide to help you get started developing locally as quickly as possible.