Cancellation in Live Tracking
Cancellation is cooperative
Cancelling a Task doesn't yank it off the CPU like force-quitting an app. It flips a flag β isCancelled β and asks nicely. Long-running async code has to actually check that flag and stop itself; ignore it, and a "cancelled" task just keeps running, burning battery and network for a screen nobody's looking at anymore.
That's exactly the risk in LiveTracker's socket loop from Module 11: receive() calls itself again after every message, forever, unless something tells it to stop. LiveTrackingView already gives you the trigger for free β .task { } automatically cancels its Task the moment the view disappears. Combine that with a cancellation check inside the loop and the socket shuts itself down exactly when the Live screen goes away, with no manual bookkeeping.