WalletConnectKotlinV2 icon indicating copy to clipboard operation
WalletConnectKotlinV2 copied to clipboard

SignClient.initialize ANR

Open ankudryavtsev opened this issue 2 years ago • 8 comments

Describe the bug An ANR occurs while initializing SignClient

SDK Version

  • Client: Android BOM
  • Version 1.4.1

To Reproduce Steps to reproduce the behaviour:

  1. Call SignClient.initialize

Expected behaviour No ANR

Screenshots If applicable, add screenshots to help explain your problem.

Device (please complete the following information): Screenshot 2023-02-21 at 16 14 43

Additional context Stacktrace 1 Stacktrace 2

ankudryavtsev avatar Feb 21 '23 16:02 ankudryavtsev

@ankudryavtsev Thanks for reporting this issue. Can you provide repro steps?

Talhaali00 avatar Feb 22 '23 14:02 Talhaali00

We call SignClient.initialize in Application.onCreate so all you need is to launch the app. It's a production issue but I managed to reproduce it with ANRWatchDog with a small timeout.

ankudryavtsev avatar Feb 22 '23 15:02 ankudryavtsev

Hey @ankudryavtsev we've created a PR with a potential fix. Could you fetch and check if it helps with your issue? We have been trying to repro but with no lack :)

jakubuid avatar Mar 14 '23 11:03 jakubuid

Hello @jakubuid @TalhaAli00. We're experiencing the same issue on the same devices after calling SignClient.initialize

This issue has 329 ANR events affecting 141 users.

Screenshot 2023-03-16 at 17 46 57

let-it-snow avatar Mar 16 '23 10:03 let-it-snow

To confirm, because I didn't include the PR in the previous comment, did you try this solution: https://github.com/WalletConnect/WalletConnectKotlinV2/pull/675 ?

Our team had trouble with the reproduction.

  • Can you share what app are we talking about?
  • Can you share a code snippet of how you initialize lib? Or by any chance is your project open source?
  • Is it happening only on Samsung devices?

jakubuid avatar Mar 16 '23 11:03 jakubuid

We didn't try this solution: #675 because also can't reproduce it. We're getting issue notifications on Firebase in production only.

Is it happening only on Samsung devices?

No, it happened on other devices too.

Can you share a code snippet of how you initialize lib? Or by any chance is your project open source?

Yes, we initialize lib like this:

class WalletApplication : Application() {
    companion object {
        var wcLibraryIsInitialize: Boolean? = null
    }

    init {
        setupBouncyCastle()
    }

    override fun onCreate() {
        super.onCreate()

        //initialization of other services

        initWC()
    }

    private fun initWC() {
        val serverUrl = "wss://${Constant.WCData.WALLET_CONNECT_URL}?projectId=${"wallet_connect_project_id"}"
        val connectionType = ConnectionType.AUTOMATIC

        try {
            CoreClient.initialize(
                relayServerUrl = serverUrl,
                connectionType = connectionType,
                application = this,
                metaData = getAppMetaData()
            ) { throwable ->
                when (throwable.throwable) {
                    is GenericException -> {
                        //do nothing
                    }
                    else -> {
                        wcLibraryIsInitialize = false
                    }
                }
            }

            if (wcLibraryIsInitialize == null) {
                SignClient.initialize(
                    Sign.Params.Init(core = CoreClient),
                    ::onWCInitializeSuccess
                ) { _ ->
                    wcLibraryIsInitialize = false
                }
            }
        } catch (exc: Exception) {
            wcLibraryIsInitialize = false
            exc.printStackTrace()
        }
    }

    private fun onWCInitializeSuccess() {
        wcLibraryIsInitialize = true
    }


    private fun getAppMetaData(): Core.Model.AppMetaData {
        return Core.Model.AppMetaData(
            name = "app",
            description = "InitDescription",
            url = "url",
            icons = listOf("https://icon.svg/"),
            redirect = "kotlin-wallet-wc:/request"
        )
    }
}

Can you share what app are we talking about?

LOBSTR wallet

let-it-snow avatar Mar 17 '23 11:03 let-it-snow

@let-it-snow can you tell if this issue is still there? Did you upgrade to the newest SDK version by any chance? 🙏

jakubuid avatar Feb 26 '24 11:02 jakubuid

@ankudryavtsev @let-it-snow what dependency injection framework do you use in your Android apps?

jakubuid avatar Feb 26 '24 14:02 jakubuid