I have a Canon EOS 1200D body with a bunch of lenses. A while back, I acquired the new Canon 50mm f/1.8 STM lens, and started noticing that the images were soft. After a bit of experimenting, I found that when I use autofocus, the image is not exactly in focus. I tried all my other lenses with the same body, but none of those other lenses seem to have the problem. On my 50mm lens, if I use the live view and autofocus, the focus is almost spot-on, but not so if I'm using the viewfinder. My understanding of backfocus is that it's caused by a misalignment in the mirror-sensor mechanism. If so, I should notice the problem on my other lenses too. What would cause only the 50mm lens to miss focus, and not any of my other lenses? And how can I correct this? (From what I know, the 1200D doesn't have the AF micro adjustment, so I can't fix it that way).
There are several possibilities of what is going on here.
Before we get too far into the hardware related issues, let's makes sure it's not user error. Modern AF systems, even on cameras such as the 1200D, are fairly sophisticated and there can be a steep learning curve to using them. For more, please see: Do the issues with sharpness I am seeing require AF fine-tuning? For how you might be just now noticing focus errors, either by user error or due to hardware issues, that have always been there please see the next section.
The next possibility is that all of your other lenses have narrower maximum apertures than the EF 50mm f/1.8 STM and so you are less likely to notice a camera or user caused focusing error when using them than when you are shooting at wider apertures with the 50mm lens.
You can use one of several methods to test if the DoF when using your other lenses is centered on where you are telling the camera to focus or if a camera focusing error is small enough that the intended focus point is not in the center but still within the range of acceptable sharpness. By pixel peeping your test images at 100% magnification you may discover that all of your lenses have a similar focusing error and that you just haven't noticed it using narrower apertures.
In addition to methods discussed in various questions here, Canon had just released a new EOS AF Microadjustment Guidebook. Although you can't actually adjust your camera using AFMA, you can use the testing methods to diagnose how severe and in which direction your focusing errors are.
What is the best way to micro-adjust a camera body to a particular lens?
Which offers better results: FoCal or LensAlign Pro?
The third possibility is that the new lens and your camera are a mis-match due to where each lies on the spectrum of allowable production tolerances. Manufacturing processes always have allowable tolerances: that is, how far from the ideal perfect blueprint a part is allowed to vary before it is deemed unusable. Both lenses and cameras will vary slightly from one example to the next of the same exact model number.
As you have noted in the question, sometimes AF issues are caused by a difference between optical distances to the imaging sensor and to the PDAF sensor via the reflex mirror, secondary mirror, and AF array microlenses. But that is not the only source of AF errors. When the camera "tells" the lens to move the focus elements a specific distance the tolerances to which the lens is made will also allow for some variation of the actual distance moved.
Sometimes the error in the camera is in one direction and the error in the lens is in the other direction and they cancel each other out very nicely. At other times both the camera and the lens introduce an error in the same direction and that causes both errors to be compounded.
For more on how a lens can introduce a focusing error, please see How can lens cause consistent front or back focus?
If you have tested your camera with other lenses and confirmed that it is properly focusing with them (even when critically looked at using 100% magnification), then you may have gotten a lens that needs to be adjusted and brought within acceptable tolerances.
Just as the camera can be factory adjusted for focusing errors, the lens is also factory adjustable to within certain tolerances. You can send both the camera and lens to Canon and request they only adjust the lens so as not to affect the camera's performance with your other lenses. If all of your other lenses are fairly good and the 50mm f/1.8 STM is the only flyer then that is the course I would recommend.
AF alignment is not a camera flaw or a lens flaw — it's a matter of how the two you have work together. Your new 50mm may be perfect out of the box for someone else's camera — and their camera wrong for all of the rest of your lenses.
Since your camera does not have a user-accessible focus adjust feature I suggest sending the camera and lens to Canon for alignment.
While it might be an autofocus issue, I'd recommend you make sure it's not the fact that you're shooting at f/1.8 with the lens all the time. :) It is extremely common, after getting their first fast lens, for a newcomer to primes to shoot with it wide open all the time. But that's where the lens is weakest. Unfortunately, in the case of the EF 50mm f/1.8 II or STM (which are optically identical), this lens is soft wide open at f/1.8 (even compared to the 18-55 STM @18mm wide open) and sharpens up considerably (and has less CA) around f/4. (Hey, it's a $100 six-element lens. What did you expect? Perfection?)
For more details and a graphic demonstration of how the corner performance on full frame of the 50/1.8 STM drastically changes with aperture setting, see the-digital-picture.com's review of the EF 50mm f/1.8 STM. On crop, and in the center it won't be quite as bad, but still noticeable.
The fact that you can't state if it's front or back focusing makes me think this may be the issue, because if it's an AMFA issue, you'd be in focus in front of or in back of your target, not softer where it's in focus.
Secondly, the DoF at f/1.8 is extremely thin, so you need much better AF accuracy. If you are using the single center AF point and recomposing, you may be moving the camera (and shifting the DoF enough) to get your subject out of focus. Consider using the other AF points.
If it really is a calibration issue, then the only way to fix it is to send your lens into Canon and have them recalibrate it. And if that doesn't work, then send in your body and the rest of your lenses to have them all recalibrated, too. And now you know why pros want the models with AFMA, so they can do it themselves.
See also: Why are my photos not crisp?
Do you see the problem at all aperture values?
There are some reports of canon losing focus for apertures wider than F2.8 using viewfinder but not in live view. Particularly with the center focus points. Try focusing with off center points and smaller apertures. I guess your other lenses have smaller apertures than F2.8 so you might not notice the problem with them.
at large apertures DOF is very small so missing focus is easy
live view is more accurate than viewfinder focusing particularly when zoomed in
Are you sure you have back/front focusing issues? It's not that you're using a ƒ1.8 lens at open aperture versus another lens at a lower stop? I'm only saying this upfront because sometimes people get picky for normal issues and don't understand why, especially with entry level camera models.
In any case, for DSLR cameras that have live view, they use both phase detection and contrast detection. When in live view, it uses contrast detection. When live view is off, it uses phase detection.
Without getting bogged down into details, this article explains phase detection but if you look at the diagram and item 7, that is the auto-focus sensor for phase detection and focuses when the mirror is down. When the mirror lifts up, and the sensor is slightly out of alignment, then the image taken will be slightly out. This is the actual cause of front/back focusing issues and will generally affect any lens you use on your body.
When in live view, the sensor uses contrast detection and is generally in the same position when the photo is taken to when it's focusing.
As suggested by mattdm, it could be a case of a mismatch of the body and lens and can be adjusted by Canon.
Before you do this, I would suggest to do some test shots using single focus (the middle point) at ƒ5.6 and use the same settings on another lens, preferably at the same focal length, if or concern is with that lens only (as also suggested [kind of] by inkista).
Even though I believe it's not a front/back focusing issue, it's still a concern that you believe you are getting different results when in live view.