I've gone to both places, Rio is a party town, even the 'Hells Angels' love it down there, you can see riding their bikes up and down Ipanema beach, Rio is 'the city that never sleeps', something is always happening. Your concerns are directly related to what part of Rio you want to go, you want to photograph the 'red light' district, Copacabana beach, 'look out', take old gear you won't risk your life to keep at the point of a knife. Ipanema beach, or an outlying environ like Baja de Tijuaca is more of a family affair, with a great deal less panhandlers/pickpockets/beggars than you find at Copacabana.
If you're 'street smart' and been to Rio before, speak a little of the language, don't 'look out of place'/'stick out like a sore thumb'(wear casual clothes, DON'T BUY NEW CLOTHES/SHOES and wear them out when you shoot), you can take calculated risks, I've been to Rio more than a dozen times, usually I keep my camera slung under my armpit, I keep moving, when I seen a group of folks staring at me, and not saying a word, I move. I keep my mouth shut, nobody knows I'm not a Carioca until I start talking.
An aside to this, is that many folks in both towns wherever you go know each other, certainly in each neighborhood, the 'word' will go out on you, 'thumbs up', or 'thumbs down', depending on how you act. If you're friendly, make friends easily, like to smile, act like you appreciate and respect Brazilians for being in their country, you'll have it easy/the risk of you getting robbed goes way down.
Bahia, is more a a lyrical place, for poets/writers/painters, beautiful, introspective, ...........and the it's less of a 'party' town than Rio, watch out for the food, if you're not use to Bahian food, eat at the hotel, if you don't, you won't have to worry about muggers, you won't be in any shape to take photographs to get robbed, you'll be in the hospital.
When in Bahia, I stay at the Marazul located at the beach, I eat there only, because they serve quite a less 'exciting' cuisine than at the restaurants, last time I was there, I made the mistake of chancing a dinner at restaurant near the hotel, I spent the whole 12 hour flight back to the state, dumping out my guts, NONSTOP, and had to see a doctor when I got back here, spending THREE DAYS IN BED. Watch what you eat.
There are pickpockets and thieves in Bahia, but it is more of a spiritual place, I bumped into about a dozen serious photographers photographing on the beach, going inland is more dangerous, but if you keep on the move(setting up on a tripod, is IFFY/taking a real chance), and relate well to the folks wherever you are when you're not on the move, this will give you your best chance,.....................if you are robbed of your gear at knifepoint, GIVE IT UP, thieves there aren't like here, they're not trying to kill you, they just want your stuff, which will feed a hungry family for quite a while.
If you don't speak any of the language, haven't been there before, better to go on a tour w/a guide your first time, because not knowing the place/where to go, you're going to 'stick out' like a 'sore thumb'. One more thing, as soon as your shoot a roll, put it in your pocket and reload, that way, if you're 'relieved' of your gear, you'll at least have what you shot.
If you've ever been to Venice beach here in LA, and you can navigate their without getting into a hassle or getting rousted, you'll be ok, if you're dressed up in sharp clothes with a gleaming new and expensive looking camera, oblivious to your surroundings, you may have some difficulties.
Good luck to you, it will always be a risk to go to either place and shoot, but the photo ops are tremendous, just tremendous, well worth the risk, go to my website to the 'Bahia' gallery to see just a few of the shots I've take during Carnaval in Bahia.