App switcher snapshots showing web views do not correctly reflect the dark mode/light mode setting

Originator:johnbrayton
Number:rdar://7213631 Date Originated:2019-09-05
Status:open Resolved:
Product:iOS Product Version:13.1 (17A5831c)
Classification:bug Reproducible:always
 
I attached a simple app with a WKWebView inside a UINavigationController. The content inside the WKWebView has a “prefers-color-scheme: dark” media query making the background black and the text color white when in dark mode. With that sample app, you can reproduce this issue:

1. Put the device in light mode, if it is not already.
2. Run the app on the device.
3. Go to the home screen.
4. Enable dark mode on the device.
5. Open the app switcher. Observe that the thumbnail for the app shows the navigation bar in dark mode but the web content in light mode.
6. Select the app in the app switcher. See the web content abruptly shift from light mode to dark mode.

You can also see this in Safari:

1. Put the device in light mode, if it is not already.
2. Open Safari and navigate to: https://www.virtualsanity.com/darkmode.html
3. Go to the home screen.
4. Enable dark mode on the device.
5. Open the app switcher. Observe that the thumbnail for Safari has the toolbar in dark mode but the web content in light mode.
6. Select Safari in the app switcher. See the web content abruptly shift from light mode to dark mode.

Seen on an iPad Air 2 running iPad OS 13.1 (17A5831c). Also seen on an iPhone X running iOS 13.1 (17A5831c).

I focused on the app switcher here because that is where you can most clearly see that the snapshots are wrong. But the user will also see symptoms of this when reopening the app by tapping it on the home screen. It looks like those snapshots are used to animate opening the app. If you have put the app into dark mode since leaving the app, you will see a sudden flash of white (or light mode content) when reopening the app.

Comments

Probably a timing issue

My guess is that the web view is updating its colors, but that this happens asynchronously and not in time for the snapshot to be saved.

By johnbrayton at Sept. 6, 2019, 11:59 a.m. (reply...)

Per tweet from Tyler Fox (Engineer on UIKit), the app receives a trait collection change and then back to take the snapshot when app enters background: https://twitter.com/smileyborg/status/1175199999367368704

I wonder if deliberately "slowing down" that trait collection request temporarily solves this issue?

By mohammad.kurabi at Oct. 6, 2019, 4:17 p.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!