Exercise 2: The Missing Cleanup, and Why It Matters for a Repeatedly-Mounted Screen — Possible Solution ==================================================================== WHAT HAPPENS IF track.stop() IS OMITTED ------------------------------ Without stopping each track on the camera's MediaStream during cleanup, the browser keeps the camera hardware active even after the React component that requested it has unmounted. The camera's "in use" indicator stays lit, the device keeps capturing frames nobody is looking at, and the stream is never actually released back to the operating system. WHY THIS MATTERS SPECIFICALLY FOR A SCAN SCREEN ------------------------------ A scan screen is exactly the kind of component a user might mount and unmount many times in one session - opening it to scan an item, navigating away, opening it again for the next item, and so on. Each mount without a proper cleanup would request a new camera stream while the previous one is still silently running, quickly leaving multiple simultaneous camera streams active, draining battery, and on some devices/browsers, eventually failing outright because too many concurrent getUserMedia streams are open at once. WHY THIS WORKS AS AN ANSWER ------------------------------ It correctly explains that omitting the cleanup leaves the camera hardware active and the stream un-released, and explains why a scan screen's repeated mount/unmount pattern makes this a compounding problem (multiple stacked active streams) rather than a one-time cosmetic issue.