aws-mobile-appsync-sdk-android icon indicating copy to clipboard operation
aws-mobile-appsync-sdk-android copied to clipboard

AppSyncOfflineMutationManager seems to block Main Thread on fresh installation of App

Open Lavanya2204-developer opened this issue 4 years ago • 8 comments

I tried using the latest SDK to implement App Sync but see below logs repeatedly when I run the application. These logs continuously print when the app is freshly installed and seem to block the UI thread as we see a black screen on the activity on which we are subscribing to events. There is no issue on subsequent launch.

V/QueueUpdateHandler: Thread:[13931]: Got message to take action on the mutation queue.
    Thread:[13931]: Got message to process next mutation if one exists.
V/AppSyncOfflineMutationManager: Thread:[13931]:Persistent mutations queue is EMPTY!. Will check inMemory Queue next
    Thread:[13931]: In Memory mutations queue was EMPTY!. Nothing to process, exiting
V/AppSyncOfflineMutationInterceptor: Thread:[13931]: processing Mutations
V/QueueUpdateHandler: Thread:[13931]: Got message to take action on the mutation queue.
    Thread:[13931]: Got message to process next mutation if one exists.
V/AppSyncOfflineMutationManager: Thread:[13931]:Persistent mutations queue is EMPTY!. Will check inMemory Queue next
    Thread:[13931]: In Memory mutations queue was EMPTY!. Nothing to process, exiting
V/AppSyncOfflineMutationInterceptor: Thread:[13931]: processing Mutations
V/QueueUpdateHandler: Thread:[13931]: Got message to take action on the mutation queue.
    Thread:[13931]: Got message to process next mutation if one exists.

Environment:

  • AppSync SDK Version: 3.1.1

Device Information:

  • Device: Samsung S21+
  • Android Version: 11
  • Specific to simulators: No

Additional context FYI, I am trying to subscribe to the App sync client inside CoroutineScope(Dispatchers.IO). We are using Amazon Cognito UserPools (AMAZON_COGNITO_USER_POOLS) as the Authentication mode

Lavanya2204-developer avatar Jun 29 '21 07:06 Lavanya2204-developer

Any update on this? I am facing exact same issue.

iamfirdous8 avatar Mar 02 '22 10:03 iamfirdous8

Can you please share code snippets and configuration json file with sensitive information removed?

div5yesh avatar Mar 07 '22 18:03 div5yesh

Hi @div5yesh

This is how we initialize the appsync client,

val awsConfig = AWSConfiguration(getJSONObject())

val regions = Regions.fromName(BuildConfig.AWS_REGION)
val cognitoUserPool = CognitoUserPool(mContext.applicationContext, awsConfig)
val basicCognitoUserPoolsAuthProvider = BasicCognitoUserPoolsAuthProvider(cognitoUserPool)
mClient = AWSAppSyncClient.builder()
        .context(mContext.applicationContext)
        .awsConfiguration(awsConfig)
        .cognitoUserPoolsAuthProvider(basicCognitoUserPoolsAuthProvider)
        .s3ObjectManager(S3ObjectManagerImplementation(AmazonS3Client(AWSMobileClient.getInstance(), Region.getRegion(regions))))
        .build()

And here's how we get the JSONObject

private fun getJSONObject(): JSONObject {
    val jsonObject = JSONObject()

    // CognitoUserPool
    val default = JSONObject()
    default.apply {
        put("PoolId", mAwsConfig.appSyncConfig?.poolId)
        put("AppClientId", mAwsConfig.appSyncConfig?.clientId)
        put("Region", BuildConfig.AWS_REGION)
    }
    val cognitoUserPool = JSONObject()
    cognitoUserPool.put("Default", default)
    jsonObject.put("CognitoUserPool", cognitoUserPool)

    // AppSync
    val appSyncDefault = JSONObject()
    appSyncDefault.apply {
        put("ApiUrl", mAwsConfig.appSyncConfig?.apiUrl)
        put("Region", BuildConfig.AWS_REGION)
        put("AuthMode", "AMAZON_COGNITO_USER_POOLS")
    }
    val appSync = JSONObject()
    appSync.put("Default", appSyncDefault)
    jsonObject.put("AppSync", appSync)

    return jsonObject
}

iamfirdous8 avatar Mar 08 '22 09:03 iamfirdous8

Any update?

iamfirdous8 avatar Apr 13 '22 07:04 iamfirdous8

@div5yesh Any update on this issue?

iamfirdous8 avatar Apr 28 '22 08:04 iamfirdous8

@iamfirdous8 are you initializing appsync sdk in the application class?

poojamat avatar May 16 '22 03:05 poojamat

Yes @poojamat, It's being initialized in the Application class.

iamfirdous8 avatar May 16 '22 08:05 iamfirdous8

@Lavanya2204-developer the log you have provided suggests that mutation queue is dealt with in a background thread what makes you believe its blocking the main thread?

poojamat avatar May 16 '22 16:05 poojamat