realm / realm-kotlin

Kotlin Multiplatform and Android SDK for the Realm Mobile Database: Build Better Apps Faster.
Apache License 2.0
943 stars 57 forks source link

kotlin.IllegalStateException: [RLM_ERR_FILE_PERMISSION_DENIED] #1656

Closed fngbala-luna closed 5 months ago

fngbala-luna commented 7 months ago

How frequently does the bug occur?

Sometimes

Description

Hi 👋 I am using realm-kotlin in a KMP project with Android and iOS. For some time now, we've experienced a large number of crashes on iOS : Caused by: kotlin.IllegalStateException: [RLM_ERR_FILE_PERMISSION_DENIED]: Failed to open file at path '/var/mobile/Containers/Data/Application/8709C61B-95B4-48BA-BB32-2BC399D5A03D/Documents/default.realm.lock': Operation not permitted

See bellow the full stacktrace (note that we use crashkIOS to have readable logs on Firebase Crashlytics : https://crashkios.touchlab.co/)

Stacktrace & log output

Could not create instance for '[Singleton:'fr.isic.enjoy.domain.usecase.user.GetUserAsFlowUseCase']' 
Caused by: org.koin.core.error.InstanceCreationException: 
Could not create instance for '[Singleton:'fr.isic.enjoy.domain.repository.UserRepository']'
 Caused by: org.koin.core.error.InstanceCreationException: Could not create instance for '[Singleton:'fr.isic.enjoy.repository.datasource.user.UserLocalDataSource']'
 Caused by: org.koin.core.error.InstanceCreationException: Could not create instance for '[Singleton:'fr.isic.enjoy.storage.dao.UserDao']' 
Caused by: org.koin.core.error.InstanceCreationException: Could not create instance for '[Singleton:'io.realm.kotlin.Realm']'
 Caused by: kotlin.IllegalStateException: [RLM_ERR_FILE_PERMISSION_DENIED]: Failed to open file at path '/var/mobile/Containers/Data/Application/8709C61B-95B4-48BA-BB32-2BC399D5A03D/Documents/default.realm.lock': Operation not permitted

Crashed: com.google.firebase.crashlytics.ios.exception
SIGABRT ABORT 0x00000001b8214964

Can you reproduce the bug?

Sometimes

Reproduction Steps

We never managed to reproduce it during development, however a lot of our users are experiencing it.

Version

1.12.0

What Atlas App Services are you using?

-- select --

Are you using encryption?

No

Platform OS and version(s)

iOS 15+

Build environment

Android Studio version: ... Android Build Tools version: ... Gradle version: ...

kneth commented 7 months ago

@fngbala-luna If you are using sync, upgrading to Realm Kotlin 1.12.0 might require that you manually delete some files (see https://github.com/realm/realm-kotlin/blob/main/CHANGELOG.md#1120-2023-11-02 for details).

fngbala-luna commented 7 months ago

Hi, thanks for your answer. However we do not use the sync feature in our project.

kneth commented 7 months ago

@fngbala-luna If the app is running as device is locked, you might have to relax the permissions.

github-actions[bot] commented 5 months ago

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.