Battery Technical Quality Enforcement is Here: How to Optimize Common Wake Lock Use Cases

Posted by Alice Yuan, Senior Developer Relations Engineer

In recognition that excessive battery drain is top of mind for Android users, Google has been taking significant steps to help developers build more power-efficient apps. On March 1st, 2026, Google Play Store began rolling out the wake lock technical quality treatments to improve battery drain. This treatment will roll out gradually to impacted apps over the following weeks. Apps that consistently exceed the “Excessive Partial Wake Lock” threshold in Android vitals may see tangible impacts on their store presence, including warnings on their store listing and exclusion from discovery surfaces such as recommendations.

Users may see a warning on your store listing if your app exceeds the bad behavior threshold.

This initiative elevated battery efficiency to a core vital metric alongside stability metrics like crashes and ANRs. The “bad behavior threshold” is defined as holding a non-exempted partial wake lock for at least two hours on average while the screen is off in more than 5% of user sessions in the past 28 days. A wake lock is exempted if it is a system held wake lock that offers clear user benefits that cannot be further optimized, such as audio playback, location access, or user-initiated data transfer. You can view the full definition of excessive wake locks in our Android vitals documentation.

As part of our ongoing initiative to improve battery life across the Android ecosystem, we have analyzed thousands of apps and how they use partial wake locks. While wake locks are sometimes necessary, we often see apps holding them inefficiently or unnecessarily, when more efficient solutions exist. This blog will go over the most common scenarios where excessive wake locks occur and our recommendations for optimizing wake locks.  We have already seen measurable success from partners like WHOOP, who leveraged these recommendations to optimize their background behavior.

Using a foreground service vs partial wake locks

We’ve often seen developers struggle to understand the difference between two concepts when doing background execution: foreground service and partial wake locks.

A foreground service is a lifecycle API that signals to the system that an app is performing user-perceptible work and should not be killed to reclaim memory, but it does not automatically prevent the CPU from sleeping when the screen turns off. In contrast, a partial wake lock is a mechanism specifically designed to keep the CPU running even while the screen is off. 

While a foreground service is often necessary to continue a user action, a manual acquisition of a partial wake lock is only necessary in conjunction with a foreground service for the duration of the CPU activity. In addition, you don’t need to use a wake lock if you’re already utilizing an API that keeps the device awake. 

Refer to the flow chart in Choose the right API to keep the device awake to ensure you have a strong understanding of what tool to use to avoid acquiring a wake lock in scenarios where it’s not necessary.

Third party libraries acquiring wake locks

It is common for an app to discover that it is flagged for excessive wake locks held by a third-party SDK or system API acting on its behalf. To identify and resolve these wake locks, we recommend the following steps:

  • Check Android vitals: Find the exact name of the offending wake lock in the excessive partial wake locks dashboard. Cross-reference this name with the Identify wake locks created by other APIs guidance to see if it was created by a known system API or Jetpack library. If it is, you may need to optimize your usage of the API and can refer to the recommended guidance.

  • Capture a System Trace: If the wake lock cannot be easily identified, reproduce the wake lock issue locally using a system trace and inspect it with the Perfetto UI. You can learn more about how to do this in the Debugging other types of excessive wake locks section of this blog post.

  • Evaluate Alternatives: If an inefficient third-party library is responsible and cannot be configured to respect battery life, consider communicating the issue with the SDK’s owners, finding an alternative SDK or building the functionality in-house.

Common wake lock scenarios

Below is a breakdown of some of the specific use cases we have reviewed, along with the recommended path to optimize your wake lock implementation.

User-Initiated Upload or Download

Example use cases: 

  • Video streaming apps where the user triggers a download of a large file for offline access.

  • Media backup apps where the user triggers uploading their recent photos via a notification prompt.

How to reduce wake locks: 

  • Do not acquire a manual wake lock. Instead, use the User-Initiated Data Transfer (UIDT) API. This is the designated path for long running data transfer tasks initiated by the user, and it is exempted from excessive wake lock calculations.

One-Time or Periodic Background Syncs

Example use cases: 

  • An app performs periodic background syncs to fetch data for offline access. 

  • Pedometer apps that fetch step count periodically.

How to reduce wake locks: 

  • Do not acquire a manual wake lock. Use WorkManager configured for one-time or periodic work.  WorkManager respects system health by batching tasks and has a minimum periodic interval (15 minutes), which is generally sufficient for background updates. 

  • If you identify wake locks created by WorkManager or JobScheduler with high wake lock usage, it may be because you’ve misconfigured your worker to not complete in certain scenarios. Consider analyzing the worker stop reasons, particularly if you’re seeing high occurrences of STOP_REASON_TIMEOUT.

workManager.getWorkInfoByIdFlow(syncWorker.id)
  .collect { workInfo ->
      if (workInfo != null) {
        val stopReason = workInfo.stopReason
        logStopReason(syncWorker.id, stopReason)
      }
  }
  • In addition to logging worker stop reasons, refer to our documentation on debugging your workers. Also, consider collecting and analyzing system traces to understand when wake locks are acquired and released.

  • Finally, check out our case study with WHOOP, where they were able to discover an issue with configuration of their workers and reduce their wake lock impact significantly.

Bluetooth Communication

Example use cases: 

  • Companion device app prompts the user to pair their Bluetooth external device.

  • Companion device app listens for hardware events on an external device and user visible change in notification.

  • Companion device app’s user initiates a file transfer between the mobile and bluetooth device.

  • Companion device app performs occasional firmware updates to an external device via Bluetooth.

How to reduce wake locks: 

  • Use companion device pairing to pair Bluetooth devices to avoid acquiring a manual wake lock during Bluetooth pairing. 

  • Consult the Communicate in the background guidance to understand how to do background Bluetooth communication. 

  • Using WorkManager is often sufficient if there is no user impact to a delayed communication. If a manual wake lock is deemed necessary, only hold the wake lock for the duration of Bluetooth activity or processing of the activity data.

Location Tracking

Example use cases: 

  • Fitness apps that cache location data for later upload such as plotting running routes

  • Food delivery apps that pull location data at a high frequency to update progress of delivery in a notification or widget UI.

How to reduce wake locks: 

  • Consult our guidance to Optimize location usage. Consider implementing timeouts, leveraging location request batching, or utilizing passive location updates to ensure battery efficiency.

  • When requesting location updates using the FusedLocationProvider or LocationManager APIs, the system automatically triggers a device wake-up during the location event callback. This brief, system-managed wake lock is exempted from excessive partial wake lock calculations.

  • Avoid acquiring a separate, continuous wake lock for caching location data, as this is redundant. Instead, persist location events in memory or local storage and leverage WorkManager to process them at periodic intervals.

override fun onCreate(savedInstanceState: Bundle?) {
    locationCallback = object : LocationCallback() {
        override fun onLocationResult(locationResult: LocationResult?) {
            locationResult ?: return
            // System wakes up CPU for short duration
            for (location in locationResult.locations){
                // Store data in memory to process at another time
            }
        }
    }
}

High Frequency Sensor Monitoring

Example use cases: 

  • Pedometer apps that passively collect steps, or distance traveled. 

  • Safety apps that monitor the device sensors for rapid changes in real time, to provide features such as crash detection or fall detection.

How to reduce wake locks: 

  • If using SensorManager, reduce usage to periodic intervals and only when the user has explicitly granted access through a UI interaction. High frequency sensor monitoring can drain the battery heavily due to the number of CPU wake-ups and processing that occurs.

  • If you’re tracking step counts or distance traveled, rather than using SensorManager, leverage Recording API or consider utilizing Health Connect to access historical and aggregated device step counts to capture data in a battery-efficient manner.

  • If you’re registering a sensor with SensorManager, specify a maxReportLatencyUs of 30 seconds or more to leverage sensor batching to minimize the frequency of CPU interrupts. When the device is subsequently woken by another trigger such as a user interaction, location retrieval, or a scheduled job, the system will immediately dispatch the cached sensor data.

val accelerometer = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER)

sensorManager.registerListener(this,
                 accelerometer,
                 samplingPeriodUs, // How often to sample data
                 maxReportLatencyUs // Key for sensor batching 
              )

  • If your app requires both location and sensor data, synchronize their event retrieval and processing. By piggybacking sensor readings onto the brief wake lock the system holds for location updates, you avoid needing a wake lock to keep the CPU awake. Use a worker or a short-duration wake lock to handle the upload and processing of this combined data.

Remote Messaging

Example use cases: 

  • Video or sound monitoring companion apps that need to monitor events that occur on an external device connected using a local network.

  • Messaging apps that maintain a network socket connection with the desktop variant.

How to reduce wake locks: 

  • If the network events can be processed on the server side, use FCM to receive information on the client. You may choose to schedule an expedited worker if additional processing of FCM data is required. 

  • If events must be processed on the client side via a socket connection, a wake lock is not needed to listen for event interrupts. When data packets arrive at the Wi-Fi or Cellular radio, the radio hardware triggers a hardware interrupt in the form of a kernel wake lock. You may then choose to schedule a worker or acquire a wake lock to process the data.

  • For example, if you’re using ktor-network to listen for data packets on a network socket, you should only acquire a wake lock when packets have been delivered to the client and need to be processed.


val readChannel = socket.openReadChannel()
while (!readChannel.isClosedForRead) {
    // CPU can safely sleep here while waiting for the next packet
    val packet = readChannel.readRemaining(1024) 
    if (!packet.isEmpty) {
         // Data Arrived: The system woke the CPU and we should keep it awake via manual wake lock (urgent) or scheduling a worker (non-urgent)
         performWorkWithWakeLock { 
              val data = packet.readBytes()
              // Additional logic to process data packets
         }
    }
}

Summary

By adopting these recommended solutions for common use cases like background syncs, location tracking, sensor monitoring and network communication, developers can work towards reducing unnecessary wake lock usage. To continue learning, read our other technical blog post or watch our technical video on how to discover and debug wake locks: Optimize your app battery using Android vitals wake lock metric. Also, consult our updated wakelock documentation. To help us continue improving our technical resources, please share any additional feedback on our guidance in our documentation feedback survey.

Responsive internet support that puts you first

Thumbnail



Get fast, reliable internet backed by award-winning, responsive customer support. We’ve invested in the people, tools, and technology to make real responsiveness the baseline, not a premium add-on. What does ‘responsive’ really mean? It’s a clear commitment reflected in our performance and customer ratings.


What is GFiber's average customer service response time?


You can see our commitment to service in our performance and customer ratings:

  • GFiber's average customer service call response time is 9 seconds.*

  • 94% of our customers give our customer service 5-star ratings, and 98% of in-home service visits are rated 5 stars.**

  • When you need to talk to a person, our team is available 24/7 by email, chat, or direct message.


More importantly, those internal performance metrics are backed up by recognition from our customers.


GFiber was ranked by J.D. Power as having the “Top Residential Wired Internet Customer Satisfaction in the South Region”***


GFiber has been recognized for “Best in Customer Satisfaction for Home Wired Internet Service in the South Region” for 3 years in a row.*** That recognition comes directly from our customers, and we’re committed to expanding our network without compromising the service that earned this award. We're here if you ever need us. The awards and metrics are just one side of the coin. When you need real help, GFiber has clear ways to reach our support team and find answers quickly.


GFiber gives you all the tools you need to troubleshoot issues 


The best first stop for most questions is our Help Center. It's the fastest way to get answers for common questions like finding your Wi-Fi password or how to run a speed test.

  • For straightforward questions, email or chat will get you a fast response.

  • For more complex issues, call us or schedule a call at a time that works for you.

  • In some of our cities, you can also visit a GFiber Space in person for hands-on help.

The GFiber App also puts a lot of troubleshooting power directly in your hands.


In-app tools for quick support

  • Network Health provides a real-time assessment of your speed, coverage, and overall performance.

  • Speed Test distinguishes between speed to your home (wired) and speed to your device (wireless).

  • TechSee lets our support agents see your connection issues in real time via video.

  • Technician Tracker shows you your technician's location and ETA when a visit is scheduled.


The app is your best companion for real-time diagnostics, a few simple checks at home can often fix minor issues.


Troubleshoot at home


If your internet is offline and you’ve checked for a known outage on fiber.google.com/outage and there's no confirmed outage in your area, start by checking your account at fiber.google.com/myfiber for any billing alerts. If that’s not the issue, use our Help Center’s step-by-step guide for troubleshooting your equipment, including your router, your Fiber Jack, and your mesh extender (if applicable) for any issues. If there’s a confirmed outage, our team is already working to resolve it. To get text updates on an outage, visit Settings in your GFiber account or text START to 434237.


Internet with a service standard you can trust


Fast, reliable internet is just the beginning. Our goal is for you to never have to think about your internet. But on the rare occasion that you do, we’ve made sure those moments are as seamless as possible. That’s why the GFiber experience is built on a foundation of award-winning customer service, quick response times, and powerful self-service tools like the GFiber app. Whether you prefer to troubleshoot on your own, talk to a representative, or receive a text update on a network outage, we ensure you have the fastest path to a resolution. With GFiber, you get the speed and reliability you need, backed by a service standard that always puts you first.


—-------------

*Based on average data from July 2022 - July 2023 data

**Based average data from January 2, 2023 - April 30, 2023 across all GFiber markets.

***[J.D. Power] GFiber received the highest score in the South region of the J.D. Power 2023-2025 U.S. Residential Internet Service Provider Satisfaction Studies, which measures customers’ satisfaction of service with their current internet provider. Visit jdpower.com/awards for more details.


OpenTitan shipping in production

Last year, we shared the exciting news that fabrication of production OpenTitan silicon had begun. Today, we're proud to announce that OpenTitan® is now shipping in commercially available Chromebooks.

The first OpenTitan part is being produced by Nuvoton, a leader in silicon security.

a close up of a blue circuit board focused on an IC

What is OpenTitan?

Over the past seven years, Google has worked with the open source communities to build OpenTitan, the first open source silicon Root of Trust (RoT). The RoT is the foundation upon which all other security properties of a device are derived, and anchoring this in silicon provides the strongest possible security guarantees that the code being executed is authorized and verified.

The OpenTitan project and its community are actively supported and maintained by lowRISC C.I.C., an independent non-profit.

OpenTitan provides the community with a high-quality, low-cost, commoditized hardware RoT that can be used across the Google ecosystem and also facilitates the broader adoption of Google-endorsed security features across the industry. Because OpenTitan is open source, you can choose to buy it from a commercial partner or manufacture it yourself based on your use case. In any of these scenarios, you can review and test OpenTitan's capabilities with a degree of transparency never afforded before in security silicon. This allows optimization for the use case at hand, whether it is having multiple reliable suppliers or ensuring the complete end-to-end control of the manufacturing process.

With OpenTitan, we are pushing the boundaries of what can be expected from a silicon RoT. For example, OpenTitan is the first commercially available open source RoT to support post-quantum cryptography (PQC) secure boot based on SLH-DSA. This helps future proof the security posture of these devices against potential adversaries with the capability to break classical public-key cryptography (e.g., RSA) via quantum computing. In addition, by applying commercial-grade design verification (DV) and top-level testing to an open source design, we have pushed for the highest quality while still allowing these chips to be transparent and independently verifiable. An added advantage of this approach is that we expect the high quality IP developed for OpenTitan to be re-usable in other projects going forward.

In addition to delivering this first instance of OpenTitan silicon as a product, we are proud of the processes that we have collaboratively developed along the way. In particular, both individual IP blocks and the top-level Earl Grey design have functional and code coverage above 90%—to the highest industry standards—with 40k+ tests running nightly. Regressions are caught and resolved quickly, ensuring design quality is maintained over the long term. Ownership transfer gives confidence that the silicon is working for you and helps to move away from co-signing so that you are in full control of your own update schedule. And since any IP is of little value without the ability to navigate and deploy it, we've prioritized thorough and accurate documentation, together with onboarding materials to streamline welcoming new developers to the project.

With lowRISC CIC and in collaboration with our OpenTitan partners, we pioneered open source security silicon development. While challenges are expected when doing something for the first time, the benefits of working in the open source have been clear: fast and efficient cross-organizational collaboration, retention of expertise regardless of employer, shared maintenance burdens, and high levels of academic research engagement.

What's next?

Firstly, bringup to deploy OpenTitan in Google's datacenters is underway and expected to land later this year.

Secondly, while we're thrilled about the advantages that this first generation OpenTitan part brings to Google's security posture, we have more on our roadmap, and have already begun work on a second generation part that will support lattice-based PQC (e.g., ML-DSA and ML-KEM) for secure boot and attestation. Stay tuned – more info on this coming soon!

Thirdly, OpenTitan started with the security use case because it is the hardest to get right. Having successfully demonstrated that we are able to deliver secure open silicon, we're confident that the same methodology can be used to develop additional open source designs targeting a wide range of use cases (whether the focus is on security, safety, or elsewhere). We're excited to see re-use of IP that was developed for OpenTitan being adapted for Caliptra, a RoT block that can be integrated into datacenter-class SoCs.

Getting Involved

OpenTitan shipping in production is a defining milestone for us and all contributors to the project. We're excited to see more open source silicon developed for commercial use cases in the future, and to see this ecosystem grow with lowRISC's introduction of new membership tiers.

As the following metrics show (baselined from the project's public launch in 2019), the OpenTitan community is rapidly growing:

  • Over ten times the number of commits at launch: from 2,500 to over 29,200.
  • 275+ contributors to the code base
  • 3.2k Github stars

If you are interested in learning more, contributing to OpenTitan, or using OpenTitan IP in one of your projects, visit the open source GitHub repository or reach out to the OpenTitan team.

Improving the connection between Google Calendar events and Google Meet calls

For each video call, Meet attempts to connect the right Calendar event to determine:

Reusing the same meeting code across multiple events can sometimes lead to ambiguity and unexpected behavior such as meeting artifacts being shared with the wrong guests (or no guests at all). We recently announced a change to reduce this ambiguity by stopping automatically copying Meet codes when duplicating Calendar events.

We are now fixing this ambiguity by having each Meet video call be tied to the initial Calendar event where it was created. This gives predictability and transparency about which guests receive notes, messages in Google Chat, recordings and other details from the meeting.

When users manually paste an old meeting code into a new Calendar event, they’ll see a dialog highlighting that the Meet code is still tied to the initial event. Codes created outside of Calendar (like instant meetings from meet.google.com) will remain unlinked.

For example:

  • If you reuse the meeting code from an old Calendar (Event A) on a new Calendar (Event B), meeting artifacts will only be shared with the host, co-hosts, and guests of the old Calendar event (Event A), and not guests of the new Calendar event (Event B).
  • If you reuse a meeting code created from meet.google.com on a new Calendar event, meeting artifacts will only be shared with the meetings host and co-hosts, and not guests of the new Calendar event.

Warnings shown when reusing a meet code

Additional details
If you use Apple Calendar to create Google Calendar events with a Google Meet meeting code, the code will be updated automatically. This change ensures that each event uses a unique meeting code. Users receive an email informing them about the update.

Getting started

  • Admins: There is no admin control for this feature.
  • End users: There is no end user setting for this feature. Visit the Help Center to learn more.

Rollout pace

Changes to behavior when creating Google Calendar event with meeting code in Apple Calendar
Changes to behavior when reusing meeting code in Google Calendar

Availability

  • Available to all Google Workspace customers and users with personal Google accounts

Resources

Improving the connection between Google Calendar events and Google Meet calls

For each video call, Meet attempts to connect the right Calendar event to determine:

Reusing the same meeting code across multiple events can sometimes lead to ambiguity and unexpected behavior such as meeting artifacts being shared with the wrong guests (or no guests at all). We recently announced a change to reduce this ambiguity by stopping automatically copying Meet codes when duplicating Calendar events.

We are now fixing this ambiguity by having each Meet video call be tied to the initial Calendar event where it was created. This gives predictability and transparency about which guests receive notes, messages in Google Chat, recordings and other details from the meeting.

When users manually paste an old meeting code into a new Calendar event, they’ll see a dialog highlighting that the Meet code is still tied to the initial event. Codes created outside of Calendar (like instant meetings from meet.google.com) will remain unlinked.

For example:

  • If you reuse the meeting code from an old Calendar (Event A) on a new Calendar (Event B), meeting artifacts will only be shared with the host, co-hosts, and guests of the old Calendar event (Event A), and not guests of the new Calendar event (Event B).
  • If you reuse a meeting code created from meet.google.com on a new Calendar event, meeting artifacts will only be shared with the meetings host and co-hosts, and not guests of the new Calendar event.

Warnings shown when reusing a meet code

Additional details
If you use Apple Calendar to create Google Calendar events with a Google Meet meeting code, the code will be updated automatically. This change ensures that each event uses a unique meeting code. Users receive an email informing them about the update.

Getting started

  • Admins: There is no admin control for this feature.
  • End users: There is no end user setting for this feature. Visit the Help Center to learn more.

Rollout pace

Changes to behavior when creating Google Calendar event with meeting code in Apple Calendar
Changes to behavior when reusing meeting code in Google Calendar

Availability

  • Available to all Google Workspace customers and users with personal Google accounts

Resources

How WHOOP decreased excessive partial wake lock sessions by over 90%

Posted by Breana Tate, Developer Relations Engineer, Mayank Saini, Senior Android Engineer, Sarthak Jagetia, Senior Android Engineer and Manmeet Tuteja, Android Engineer II


Building an Android app for a wearable means the real work starts when the screen turns off. WHOOP helps members understand how their body responds to training, recovery, sleep, and stress, and for the many WHOOP members on Android, reliable background syncing and connectivity are what make those insights possible.


Earlier this year, Google Play released a new metric in Android vitals: Excessive partial wake locks. This metric measures the percentage of user sessions where cumulative, non-exempt wake lock usage exceeds 2 hours in a 24-hour period. The aim of this metric is to help you identify and address possible sources of battery drain, which is crucial for delivering a great user experience.


Beginning March 1, 2026, apps that continue to not meet the quality threshold may be excluded from Google Play discovery surfaces. A warning may also be placed on the Google Play Store listing, indicating the app might use more battery than expected.


According to Mayank Saini, Senior Android Engineer at WHOOP,  this “presented the team with an opportunity to raise the bar on Android efficiency,” after Android vitals flagged the app’s excessive partial wake lock % as 15%—which exceeded the recommended 5% threshold.




The team viewed the Android vitals metric as a clear signal that their background work was holding the CPU awake longer than necessary. Resolving this would allow them to continue to deliver a great user experience while simultaneously decreasing wasted background time and maintaining reliable and timely Bluetooth connectivity and syncing.


Identifying the issue


To figure out where to get started, the team first turned to Android vitals for more insight into which wake locks were affecting the metric. By consulting the Android vitals excessive partial wake locks dashboard, they were able to identify the biggest contributor to excessive partial wake locks as one of their WorkManager workers (identified in the dashboard as androidx.work.impl.background.systemjob.SystemJobService). To support the WHOOP “always-on experience”, the app uses WorkManager for background tasks like periodic syncing and delivering recurring updates to the wearable. 


While the team was aware that WorkManager acquires a wake lock while executing tasks in the background, they previously did not have visibility into how all of their background work (beyond just WorkManager) was distributed until the introduction of the excessive partial wake locks metric in Android vitals.


With the dashboard identifying WorkManager as the main contributor, the team was then able to focus their efforts on identifying which of their workers was contributing the most and work towards resolving the issue.


Making use of internal metrics and data to better narrow down the cause


WHOOP already had internal infrastructure set up to monitor WorkManager metrics. They periodically monitor:

  1. Average Runtime: For how long does the worker run?

  2. Timeouts: How often is the worker timing out instead of completing?

  3. Retries: How often does the worker retry if the work timed out or failed?

  4. Cancellations: How often was the work cancelled?


Tracking more than just worker successes and failures gives the team visibility into their work’s efficiency.


The internal metrics flagged high average runtime for a select few workers, enabling them to narrow the investigation down even further. 


In addition to their internal metrics, the team also used Android Studio’s Background Task Inspector to inspect and debug the workers of interest, with a specific focus on associated wake locks, to align with the metric flagged in Android vitals.


Investigation: Distinguishing between worker variants


WHOOP uses both one-time and periodic scheduling for some workers. This allows the app to reuse the same Worker logic for identical tasks with the same success criteria, differing only in timing.


Using their internal metrics made it possible to narrow their search to a specific worker, but they couldn't tell if the bug occurred when the worker was one-time, periodic, or both. So, they rolled out an update to use WorkManager’s setTraceTag method to distinguish between the one-time and periodic variants of the same Worker.


This extra detail would allow them to definitively identify which Worker variant (periodic or one-time) was contributing the most to sessions with excessive partial wake locks. However, the team was surprised when the data revealed that neither variant appeared to be contributing more than the other.


Manmeet Tuteja, Android Engineer II at WHOOP said “that split also helped us confirm the issue was happening in both variants, which pointed away from scheduling configuration and toward a shared business logic problem inside the worker implementation.”




Diving deeper on worker behavior and fixing the root cause


With the knowledge that they needed to take a look at logic within the worker,  the team re-examined worker behavior for the workers that had been flagged during their investigation. Specifically, they were looking for instances in which work may have been getting stuck and not completing.


All of this culminated in finding the root cause of the excessive wake locks:


A CoroutineWorker that was designed to wait for a connection to the WHOOP sensor before proceeding. 


If the work started with no sensor connected, whoopSensorFlow–which indicates if the sensor is connected– was null. The SensorWorker didn’t treat this as an early-exit condition and kept running, effectively waiting indefinitely for a connection. As a result, WorkManager held a partial wake lock until the work timed out, leading to high background wake lock usage and frequent, unwanted rescheduling of the SensorWorker.


To address this, the WHOOP team updated the worker logic to check the connection status before attempting to execute the core business logic.


If the sensor isn’t available, the worker exits, avoiding a timeout scenario and releasing the wake lock. The following code snippet shows the solution:


class SensorWorker(appContext: Context, params: WorkerParameters): CoroutineWorker(appContext, params) {
   override suspend fun doWork(): Result {
      ...
      // Check the sensor state and perform work or return failure
       return whoopSensorFlow.replayCache
            .firstOrNull()
            ?.let { cachedData ->
                processSensorData(cachedData)
                Result.success()
            } ?: run {
                Result.failure()
            }
}


Achieving a 90% decrease in sessions with excessive partial wake locks


After rolling out the fix, the team continued to monitor the Android vitals dashboard to confirm the impact of the changes. 


Ultimately, WHOOP saw their excessive partial wake lock percentage drop from 15% to less than 1% just 30 days after implementing the changes to their Worker.


As a result of the changes, the team has seen fewer instances of work timing out without completing, resulting in lower average runtimes. 


The WHOOP team’s advice to other developers that want to improve their background work’s efficiency:






Get Started

If you’re interested in trying to reduce your app’s excessive partial wake locks or trying to improve worker efficiency, view your app’s excessive partial wake locks metric in Android vitals, and review the wake locks documentation for more best practices and debugging strategies.