I'm flying AC in June from LAX-YYZ-SCL, and LIM-YYZ-LAX in August. I'm a citizen of Thailand, so I basically need a Canadian visa. However, as I'm flying AC into their home airport with the US border preclearance facilities (I have a valid US visa as well), someone told me that I might not have to apply for the Canadian transit visa. So do I really need it during the transfer at YYZ?

On the outbound you will hang a left before the escalators heading to the main customs hall. Here there will be a cursory document check by Canadian immigration. You should be permitted through since you will be in a sterile area of the airport (and won't even have to go through security either). However, I would call AC to confirm that no transit visa will be required. (If I remember next week when I return from FRA, I will stop by the agents who do this check and ask about your case.) It shouldn't be given the internal routing you take at the airport.

On the return there should be no issue as long as your US visa is valid since you won't even see Canadian officials and be directed, as you note, to US pre clearance.

Thank you so much! I just realized that they just allowed TWOV for Thai citizens in YYZ and YVR last year! I used to think that I need a transit visa, and plan to get one in LA in a few weeks. At least I won't have to waste my time in LA!