Skip to content

Android release bundling holds the Gradle project lock during external commands #60600

Backlog

Description

@roryabraham

Description

On Android, createBundle<Variant>JsAndAssets runs the external bundler, Hermes, and source-map composition synchronously in BundleHermesCTask's task action. That action holds Gradle's project lock. Independent native work in the same Android project, such as CMake compilation, can sit idle for the entire bundle even with --parallel and available workers.

Submitting the existing command sequence as one WorkerExecutor.noIsolation() work item lets Gradle run independent work while still tracking the bundle task's completion, failures and outputs.

Steps to reproduce

On Gradle 9.4.1, put this build.gradle in an empty project. It isolates the scheduling behavior of the task without needing the Android SDK or a running bundler:

import org.gradle.process.ExecOperations
import org.gradle.workers.WorkAction
import org.gradle.workers.WorkParameters
import org.gradle.workers.WorkerExecutor
import javax.inject.Inject

abstract class BundleWorker implements WorkAction<WorkParameters.None> {
    @Inject abstract ExecOperations getExecOperations()
    void execute() {
        execOperations.exec { commandLine 'sh', '-c', 'echo bundle-start; sleep 3; echo bundle-done' }
    }
}

abstract class Bundle extends DefaultTask {
    @Inject abstract ExecOperations getExecOperations()
    @Inject abstract WorkerExecutor getWorkerExecutor()
    @TaskAction void bundle() {
        if (project.hasProperty('worker')) {
            workerExecutor.noIsolation().submit(BundleWorker) {}
        } else {
            execOperations.exec { commandLine 'sh', '-c', 'echo bundle-start; sleep 3; echo bundle-done' }
        }
    }
}
tasks.register('bundle', Bundle)
tasks.register('nativeCompile') {
    doLast { println 'native-compile' }
}

Run gradle --parallel --max-workers=2 --console=plain bundle nativeCompile, then run the same command with -Pworker. In the first run, native-compile prints after bundle-done. With the worker it can run before the bundle completes.

Version and build data

Measured in a clean, two-ABI Android build using React Native 0.88.1 on macOS arm64 with Gradle 9.4.1 and JDK 17. The same synchronous action is present on current main. The downstream experiment took 516.11s before the change and 451.60s after it, with CMake overlapping bundling for 98.72s. Downstream measurements and artifact checks.

Activity

  1. added
    Needs: Repro
    on Dec 5, 2026
  2. react-native-bot commented on Dec 5, 2026

    @react-native-bot
    Collaborator

    Warning

    Missing reproducer: We could not detect a reproducible example in your issue report. Reproducers are mandatory and we can accept only one of those as a valid reproducer:


    You can read more about about it on our website: How to report a bug.

  3. roryabraham commented on Dec 5, 2026

    @roryabraham
    Author

    The implementation is available for review in #60601. The Gradle plugin tests and the isolated bundle fixtures passed.

  4. added
    Needs: Attention
    and removed on Dec 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: AttentionNeeds: Repro

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions