The ball is out of play only when it has wholly crossed the touchline or goal line, on the ground or in the air. The line is part of the field. That is why a ball balanced on the line is still in play.
The myth to drop
Myth: the referee guesses. Officials are taught a single phrase — "whole ball, whole line" — and goal-line technology settles the rest.