Backport patch for bug 1338614

Background resizing was happening in the foreground