realm / realm-swift

Realm is a mobile database: a replacement for Core Data & SQLite
https://realm.io
Apache License 2.0
16.34k stars 2.15k forks source link

macOS Sequoia - iOS Simulator gets stuck infinitely when running unit tests #8704

Closed radudanqonto closed 1 month ago

radudanqonto commented 1 month ago

How frequently does the bug occur?

Sometimes

Description

Hi Team! đź‘‹

We are seeing a bug on macOS Sequoia related to the test running. When attempting to run tests, the iOS simulator becomes stuck indefinitely. This can occur whether we run tests for a specific module, all unit tests, or even a single test.

We narrowed down the issue and is due to failing to copy the realm DB named pipes (FIFO):

We saw in the CoreSimulator log file the following error:

NSCocoaErrorDomain Code=512 ""access_control.new_commit.cv" couldn't be copied

The copy fails and then a new clone of the simulator is created retrying the process. And this goes on and on.

What is happening?

When running our iOS app on the simulator, a list of folders is created, including one Shared/AppGroup. Under the AppGroup folder, the list of multiple UDIDs corresponds to the specific App Group containers created for individual app targets or extensions that are sharing data within that App Group.

Screenshot 2024-10-30 at 22 32 38

One of these folders contains the Realm DB files. There are a few files called named pipes which are invisible in Finder (even if you have hidden files to true). You need to list them with ls -l.

So, when we select the test target and run the tests, the OS clones the permanent simulator and copies all files from its folders. All files are being copied except those pipes.

When the OS attempts to copy the pipes, the operation fails with the error Code=512.

Are there any workarounds available?

Yes. We found that running the tests works if we first “Erase All Content and Settings” from the simulator.

Another workaround is to remove all simulators and reinstall the iOS runtimes. This prevents the issue for a longer period (almost a full day), but eventually, the problem reoccurs.

Alternatively, we can delete the named pipes from the App Groups directory before running the tests.

Have we tried to give full disk permissions

Yes, we tried to give full disk permissions to a lot of things (Xcode, simulator, file paths, directories, etc.) but with no luck. We still get the same error.

Is the issue happening on a specific version of Xcode?

No, it happens for multiple Xcode versions:

Is the issue happening on a specific macOS Sequoia version?

No, it happens on multiple macOS Sequoia versions:

Stacktrace & log output

Oct 29 17:41:18 CoreSimulatorService[14079] <Error>: New device is stuck in creation state, deleting: Clone 712 of iPhone SE (3rd generation) (58D6DED6-2C55-4E7C-BBB4-E0D661DC41A1, iOS 18.1, Creating)
Oct 29 17:41:20 CoreSimulatorService[14079] <Error>: Error Domain=NSPOSIXErrorDomain Code=22 "Invalid argument" UserInfo={NSLocalizedFailureReason=Device was allocated but was stuck in creation state. Check CoreSimulator.log for more information.}
Oct 29 17:41:20 com.apple.dt.Xcode[90147] <Error>: Error Domain=NSPOSIXErrorDomain Code=22 "Invalid argument" UserInfo={NSLocalizedFailureReason=Device was allocated but was stuck in creation state. Check CoreSimulator.log for more information.}
Oct 29 17:41:30 CoreSimulatorService[14079] <Warning>: Device 6C270BDB-2945-42B5-A985-884F93BFD3E1 encountered in creation state at launch. The device will be re-created.
Oct 29 17:41:38 CoreSimulatorService[14079] <Error>: Failed to clone the device data path, error = Error Domain=NSCocoaErrorDomain Code=512 "“access_control.new_commit.cv” couldn’t be copied to “db.realm.management”." UserInfo={NSSourceFilePathErrorKey=[...]/db.realm.management/access_control.new_commit.cv, NSUserStringVariant=(
    Copy
), NSDestinationFilePath=[...]/db.realm.management/access_control.new_commit.cv, NSUnderlyingError=0x600000ffa490 {Error Domain=NSPOSIXErrorDomain Code=45 "Operation not supported"}}
Oct 29 17:41:38 CoreSimulatorService[14079] <Error>: Failed to re-create device that was encountered in the creation state (Clone 713 of iPhone SE (3rd generation) (6C270BDB-2945-42B5-A985-884F93BFD3E1, iOS 18.1, Creating)): Error Domain=NSCocoaErrorDomain Code=512 "“access_control.new_commit.cv” couldn’t be copied to “db.realm.management”." UserInfo={NSSourceFilePathErrorKey=[...]/db.realm.management/access_control.new_commit.cv, NSUserStringVariant=(
    Copy
), NSDestinationFilePath=[...]/db.realm.management/access_control.new_commit.cv, NSUnderlyingError=0x600000ffa490 {Error Domain=NSPOSIXErrorDomain Code=45 "Operation not supported"}}
Oct 29 17:41:40 CoreSimulatorService[14079] <Error>: Error Domain=NSPOSIXErrorDomain Code=22 "Invalid argument" UserInfo={NSLocalizedFailureReason=Device was allocated but was stuck in creation state. Check CoreSimulator.log for more information.}
Oct 29 17:41:50 CoreSimulatorService[14079] <Warning>: Device C6DEBFBB-6EFA-4E4C-B51B-9DDA08AF9BDB encountered in creation state at launch. The device will be re-created.
Oct 29 17:41:55 CoreSimulatorService[14079] <Error>: Failed to clone the device data path, error = Error Domain=NSCocoaErrorDomain Code=512 "“access_control.new_commit.cv” couldn’t be copied to “db.realm.management”." UserInfo={NSSourceFilePathErrorKey=[...]/db.realm.management/access_control.new_commit.cv, NSUserStringVariant=(
    Copy
), NSDestinationFilePath=[...]/db.realm.management/access_control.new_commit.cv, NSUnderlyingError=0x600000ffb000 {Error Domain=NSPOSIXErrorDomain Code=45 "Operation not supported"}}
Oct 29 17:42:06 CoreSimulatorService[14079] <Warning>: Device 032BAE7E-E345-48F2-86EB-4DF1AD4D5291 encountered in creation state at launch. The device will be re-created.

Can you reproduce the bug?

Always

Reproduction Steps

  1. Run the iOS app on a simulator (e.g. iPhone SE 3rd gen. with iOS 18.1).
  2. Quit Xcode and the iOS simulator.
  3. Select a test target to run.
  4. Select the same simulator you previously ran the iOS app.
  5. Run the tests (CMD + U).
  6. The simulator is now stuck.

Version

10.54.1

What Atlas Services are you using?

Local Database only

Are you using encryption?

Yes

Platform OS and version(s)

macOS Sequoia 15.0, iOS 18.0, iOS 18.1

Build environment

Xcode version: ... Dependency manager and version: ...

sync-by-unito[bot] commented 1 month ago

➤ PM Bot commented:

Jira ticket: RCOCOA-2448

radudanqonto commented 1 month ago

Duplicated with https://github.com/realm/realm-swift/issues/8705