I plan to leave Guangzhou for Istanbul at the end of July. The departure will be transferred at RUH Airport in Riyadh (stay about 3 hours), and the return will be transferred at JED Airport in Jeddah (stay about 8 hours). I know that if I stay at the above two airports for no more than 12 hours, I do not need to apply for a transit visa, but my ticket is not a onward ticket.(SV885 from Guangzhou to Riyadh and SV277 from Riyadh to Istanbul) In addition, I do not know whether I need to leave the international transit area (Departures and arrivals are from the same terminal）
Do I really need to apply for a transit visa? This is my first international travel, any detailed answer will be appreciated.