Merge "Free up all scratch resources when the app's UI is hidden" into pi-dev