aws-mobile-appsync-sdk-android
aws-mobile-appsync-sdk-android copied to clipboard
AppSyncOfflineMutationManager seems to block Main Thread on fresh installation of App
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
Any update on this? I am facing exact same issue.
Can you please share code snippets and configuration json file with sensitive information removed?
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
}
Any update?
@div5yesh Any update on this issue?
@iamfirdous8 are you initializing appsync sdk in the application class?
Yes @poojamat, It's being initialized in the Application class.
@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?