With the introduction of Doze in Marshmallow, app developers and users had to find the perfect balance between battery life and background activity. Granular options for battery optimization exist on most Android devices, allowing you to single out apps you'd like to give free rein to. This can be crucial for backup apps (Google Photos), companion apps for wearables (Fitbit, Wear), and smart home security apps that require your location to arm or disarm (Nest, SmartThings).
However, some phones like the ones from OnePlus limit your access to battery optimization settings for system apps, specifically, meaning you can't give Google Photos the freedom to run whenever it needs to, which usually results in stalled backups. It's not until a user manually opens Photos that the app begins uploading the pending media, resulting in a sub-optimal experience. Thankfully though, there's a workaround.
If you head over to Settings on a OnePlus phone, then Battery > Battery optimization, you'll find a limited list of apps you can control. It lacks all pre-installed system apps. However, the full-blown list is there, it's just hidden behind an unknown activity.
Left: Regular battery optimization menu. Right: Hidden menu with system apps.
To trigger it, you need a way to launch an activity on Android. There are many apps for this on the Play Store (eg: Activity Manager: Hidden activity launcher), but you can also do it with Nova Launcher. Add a widget to your homescreen, choose the Activities shortcut from Nova, scroll down in the list to Settings, then find the Battery optimization activity which corresponds to .Settings$HighPowerApplicationsActivity.
With the widget on your homescreen, you can now easily access the hidden menu. By default, it'll show you the apps that aren't optimized, but you can switch to view all apps. There, you'll be able to find system apps like Google Photos, Maps, Drive, Gmail, Chrome, Gboard, Play Store, Play Services, and more. If you want one of these to run unrestricted in the background, you simply have to select it, then choose Don't optimize. Those of you who have issues with Photos backups stalling until the app is opened might want to consider changing that setting.
Stopping battery optimization for Google Photos.
The choices you make on this screen survive a reboot, but keep in mind that OnePlus phones had a tendency to discard battery optimization settings after a while, so you should make sure your choices are intact every few weeks.