Why do iPhones sometimes forget battery usage by app (Settings > Battery)?

Power usage logs are a low priority item and if that subsystem crashes or the device runs low on space, I've seen it nor populate until a restart. If you restart and the battery isn't 100% - that also suppresses the usage.

In dire cases - a backup and restore is needed to remedy the software and filesystem issues that could cause this function to not work at all.