Can you spot the difference between an African and European swallow? I bet you can't. But a professional bird watcher could tell them apart in a second.
Same thing with protestors. When I was active I could easily tell the difference between someone potentially violent and someone peaceful. Woman with a stroller - probably peaceful. Person in all black with a large backpack - potentially violent. Admittedly, this was many years ago but I don't think rioters are any harder to spot these days.
Thing is, most riots are planned and not spontaneous events. Troublemakers infiltrate the crowds and try to cause confrontations with the police. The police reacts with heavy handedness causing those who are peaceful to sympathize with the troublemakers. More of them join the troublemakers side causing more confrontations and eventually it spirals out of control.
The simple solution to this problem is for the police to target the troublemakers and to let the peaceful protestors be. It actually is that easy because organizers almost always knows who the troublemakers are and would share that info with the police. But the police isn't interested. I suspect that is because by and large they love riots just as much as the rioters.