I remember seeing some explanation from a English grammar book, written for people speaking another language, which basicaly said "when/while doing something" is just a shorthand of "when/while somebody is doing something", where "somebody is" must appear in the main clause, otherwise this shorthand usage is not valid. For example, it is wrong to say
“I watch TV, when sitting in my sofa.”
because in the main clause there is no "be".
This isn’t quite correct. It’s a bit better if the somebody appears in the main clause. The is doesn’t need to appear in the main clause at all.
An awesome sunset is a routine occurrence when chasing across the treeless Great Plains. (almost entirely ok)
This might sound a little bit odd to some people because the somebody (whoever is chasing) is completely missing from the main clause. But to a lot of people it will sound just fine. In ordinary speech, almost no one would notice.
One day, while looking through his grandparents’ attic, he found some old photographs. (definitely ok)
This one is impeccable. The implied subject of looking is the he of he found. Note that *“he was finding some old photographs” would be wrong.
Traditionally, while and when are called subordinating conjunctions. Some modern grammarians call them prepositions. Whatever you call them, they are followed by a clause: either an ordinary declarative clause (while Kaitlin worked on her paper), an -ing clause (while watching TV), a past-participial clause (when forced to respond), or a verbless clause (while in Rome, while an ice cream man in Hawaii, when drunk). Except in the first case, the subject of the dependent clause has to be figured out from context, and the verb be is implied.