Thanks Simon Charette for the solution and analysis. Backport of 4237050684427db45ea834fe89d9e11c0520201e from master