Skip to content

[SDK] Crash during session initialisation due to crypto_store.realm decryption failure #9089

@jaydeep-p-simform

Description

@jaydeep-p-simform

Description

While initializing a Matrix session using createSessionFromSso, the SDK sometimes crashes with a RealmFileException indicating that the crypto_store.realm file decryption fails.

Manually clearing app data resolves the issue, but that's not the fix.

Can you please help resolve it?

Session Initialisation:

 fun initializeSession(
    userId: String,
    accessToken: String,
    homeServer: String,
    deviceId: String
) {
    val homeServerConnectionConfig = HomeServerConnectionConfig
        .Builder()
        .withHomeServerUri((URL_PREFIX + homeServer).toUri())
        .build()

    val credential = Credentials(
        userId = userId,
        accessToken = accessToken,
        homeServer = homeServer,
        refreshToken = null,
        deviceId = deviceId
    )

    session = matrix.authenticationService().createSessionFromSso(
        homeServerConnectionConfig,
        credential
    )
}

Crash Logs:

java.lang.RuntimeException: Unable to create application us.ocgo.app.OcgoApp: io.realm.exceptions.RealmFileException: Unable to open a realm at path '/data/user/0/com.telware.hdmeet/files/crypto_store.realm': Realm file decryption failed Path:Exception backtrace:
<backtrace not supported on this platform>. (Realm file decryption failed Path: /data/user/0/com.telware.hdmeet/files/crypto_store.realm
Exception backtrace:
<backtrace not supported on this platform>) (/data/user/0/com.telware.hdmeet/files/crypto_store.realm) in /tmp/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_OsSharedRealm.cpp line 107 Kind: ACCESS_ERROR.
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7003)
    at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2236)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loopOnce(Looper.java:205)
    at android.os.Looper.loop(Looper.java:294)
    at android.app.ActivityThread.main(ActivityThread.java:8177)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions