Partly revert [20969]. fix #1311