Search Issue Tracker

By Design

Votes

0

Found in

2019.4

2019.4.27f1

2020.3

2021.1

2021.2

Issue ID

1339409

Regression

No

[iOS] Deadlock when sync loading from main-thread a terrain/mesh marked for async upload and having a Unity Job running

Mobile

-

Reproduction steps:
1. Download and open the attached "ReproCase_DeadlockJobsSyncLoadAsyncMesh.zip" project
2. Build and deploy the project to iOS
3. Press the "Deadlock" button

Expected result: The application doesn't freeze
Actual result: The application freezes

Reproducible with: 2019.4.28f1, 2020.3.12f1, 2021.1.11f1, 2021.2.0a21
Could not test with: 2018.4 (Project breaks when downgrading, console errors)

Reproduced with: iPhone 12 Pro (iOS 14.2.1), iPhone 6S (iOS 13.3.1)
Not reproducible with: Xiaomi MI 8 Lite (MI 8 Lite), Android 9, CPU: Snapdragon 660, GPU: Adreno (TM) 512
VLNQA00332, Samsung Galaxy XCover4 (SM-G390F), Android 9, CPU: Exynos 7 Quad 7570, GPU: Mali-T720
VLNQA00381, Xiaomi Redmi Note 8 Pro (Redmi Note 8 Pro), Android 9, CPU: MediaTek Helios G90T MT6785T, GPU: Mali-G76 MC4
VLNQA00099, Google Pixel XL (Pixel XL), Android 10, CPU: Snapdragon 821 MSM8996 Pro, GPU: Adreno (TM) 530
VLNQA00052, Xiaomi MI MAX (MI MAX), Android 7.0, CPU: Snapdragon 617 MSM8952, GPU: Adreno (TM) 510;
macOS Big Sur, Windows

  1. Resolution Note (2022.1.X):

    The problem experienced in this case is due to improper use of job system.
    What happens is that job thread does a busy spin waiting for signal from main thread, while main thread performs load which in turn internally submit jobs to job queue and wait for them to finish. If job system has only one thread, jobs in queue never get executed.

    Unity job system is designed with assumption that jobs use dependencies and never block. Hence, a job like in this case is improper use of job system. If something like that is needed, one should use regular threads instead and proper synchronization primitives to prevent busy-spins, which waste CPU time.

    We will improve job system to make number of threads configurable to some degree, which would help, but is beyond the scope of this case.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.