[3.36] Backport more viewport fixes
Backport !1831 (merged) and !1836 (merged). !1832 (merged) is apparently not needed, as it fixed a regression from the graphene port (see !1832 (comment 1088083))
The main motivation to backport this to 3.36 is to get it into Ubuntu 20.04 eventually, as it is used by some CIs, among them the FF one.