Them idle ring is clearly very worn in the peak power zones (6&12 when the crank is horizontal).
IMO this CAN cause the chain to fall off via the same mechanism that causes skipping on worn rear sprockets. Doubly so if you get more issues on less aligned gear combinations.
So definitely consider a new sprocket, since this one is toast or beauty so. However, I suspect that the chain is probably equally near the end of it's life. So check that too, so the old chain doesn't kill the new sprocket.
__________________
FB
Chain-L site
An ounce of diagnosis is worth a pound of cure.
Just because I'm tired of arguing, doesn't mean you're right.
“One accurate measurement is worth a thousand expert opinions” - Adm Grace Murray Hopper - USN
WARNING, I'm from New York. Thin skinned people should maintain safe distance.