Ecological collapse and the emergence of travelling waves at the onset of shear turbulence