Lock state before we modify. Upstream-commit: eaeb969138205349c08e485c0bc4d29dbe2567d7 Component: engine