Description
Describe the bug
We have debounce 500ms for user search and if user type text to search for address, we will kill the previous job and create new search for place index request to get the Address suggestions
Regression Issue
- Select this option if this issue appears to be a regression.
Expected behavior
It should not crash the application since the network operation(AWS library internal implementation) is not on the main thread to call AWS location APIs
Current behavior
Some of the users when they try to search for place index is crashing:
at aws.smithy.kotlin.runtime.http.engine.CoroutineUtilsKt$attachToOuterJob$cleanupHandler$1.invoke(CoroutineUtils.kt:51) at aws.smithy.kotlin.runtime.http.engine.CoroutineUtilsKt$attachToOuterJob$cleanupHandler$1.invoke(CoroutineUtils.kt:49)
Caused by kotlinx.coroutines.CompletionHandlerException: Exception in completion handler v0@eae879c[job@c4975a5] for y0{Cancelled}@c4975a5
at kotlinx.coroutines.JobSupport.notifyCompletion(JobSupport.kt:1506)
at kotlinx.coroutines.JobSupport.completeStateFinalization(JobSupport.kt:322)
at kotlinx.coroutines.JobSupport.finalizeFinishingState(JobSupport.kt:239)
at kotlinx.coroutines.JobSupport.tryMakeCompletingSlowPath(JobSupport.kt:917)
at kotlinx.coroutines.JobSupport.tryMakeCompleting(JobSupport.kt:874)
at kotlinx.coroutines.JobSupport.cancelMakeCompleting(JobSupport.kt:707)
at kotlinx.coroutines.JobSupport.cancelImpl$kotlinx_coroutines_core(JobSupport.kt:678)
at kotlinx.coroutines.JobSupport.cancelInternal(JobSupport.kt:643)
at kotlinx.coroutines.JobSupport.cancel(JobSupport.kt:628)
at aws.smithy.kotlin.runtime.http.engine.CoroutineUtilsKt$attachToOuterJob$cleanupHandler$1.invoke(CoroutineUtils.kt:51)
at aws.smithy.kotlin.runtime.http.engine.CoroutineUtilsKt$attachToOuterJob$cleanupHandler$1.invoke(CoroutineUtils.kt:49)
at kotlinx.coroutines.InternalCompletionHandler$UserSupplied.invoke(CompletionHandler.common.kt:67)
at kotlinx.coroutines.InvokeOnCancelling.invoke(JobSupport.kt:1438)
at kotlinx.coroutines.JobSupport.notifyCancelling(JobSupport.kt:1483)
at kotlinx.coroutines.JobSupport.tryMakeCancelling(JobSupport.kt:806)
at kotlinx.coroutines.JobSupport.makeCancelling(JobSupport.kt:766)
at kotlinx.coroutines.JobSupport.cancelImpl$kotlinx_coroutines_core(JobSupport.kt:682)
at kotlinx.coroutines.JobSupport.parentCancelled(JobSupport.kt:648)
at kotlinx.coroutines.ChildHandleNode.invoke(JobSupport.kt:1446)
at kotlinx.coroutines.JobSupport.notifyCancelling(JobSupport.kt:1483)
at kotlinx.coroutines.JobSupport.tryMakeCancelling(JobSupport.kt:806)
at kotlinx.coroutines.JobSupport.makeCancelling(JobSupport.kt:766)
at kotlinx.coroutines.JobSupport.cancelImpl$kotlinx_coroutines_core(JobSupport.kt:682)
at kotlinx.coroutines.JobSupport.parentCancelled(JobSupport.kt:648)
at kotlinx.coroutines.ChildHandleNode.invoke(JobSupport.kt:1446)
at kotlinx.coroutines.JobSupport.notifyCancelling(JobSupport.kt:1483)
at kotlinx.coroutines.JobSupport.tryMakeCancelling(JobSupport.kt:806)
at kotlinx.coroutines.JobSupport.makeCancelling(JobSupport.kt:766)
at kotlinx.coroutines.JobSupport.cancelImpl$kotlinx_coroutines_core(JobSupport.kt:682)
at kotlinx.coroutines.JobSupport.parentCancelled(JobSupport.kt:648)
at kotlinx.coroutines.ChildHandleNode.invoke(JobSupport.kt:1446)
at kotlinx.coroutines.JobSupport.notifyCancelling(JobSupport.kt:1483)
at kotlinx.coroutines.JobSupport.tryMakeCancelling(JobSupport.kt:806)
at kotlinx.coroutines.JobSupport.makeCancelling(JobSupport.kt:766)
at kotlinx.coroutines.JobSupport.cancelImpl$kotlinx_coroutines_core(JobSupport.kt:682)
at kotlinx.coroutines.JobSupport.parentCancelled(JobSupport.kt:648)
at kotlinx.coroutines.ChildHandleNode.invoke(JobSupport.kt:1446)
at kotlinx.coroutines.JobSupport.notifyCancelling(JobSupport.kt:1483)
at kotlinx.coroutines.JobSupport.tryMakeCancelling(JobSupport.kt:806)
at kotlinx.coroutines.JobSupport.makeCancelling(JobSupport.kt:766)
at kotlinx.coroutines.JobSupport.cancelImpl$kotlinx_coroutines_core(JobSupport.kt:682)
at kotlinx.coroutines.JobSupport.cancelInternal(JobSupport.kt:643)
at kotlinx.coroutines.JobSupport.cancel(JobSupport.kt:628)
at kotlinx.coroutines.Job$DefaultImpls.cancel$default(Job.kt:195)
Steps to Reproduce
We could not be able to reproduce on it our end but we can see lot our end users are getting this and cause the crash the app
val locationCredentialsProvider: LocationCredentialsProvider =
AuthHelper(context).authenticateWithCognitoIdentityPool("xxxxxxxxxx")
val locationClient: LocationClient = locationCredentialsProvider.getLocationClient()
val request = SearchPlaceIndexForSuggestionsRequest {
text = "sydney"
indexName = "xxxxx"
}
val response = locationClient.searchPlaceIndexForSuggestions(request)
Caused by android.os.NetworkOnMainThreadException:
at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1605)
at com.android.org.conscrypt.Platform.blockGuardOnNetwork(Platform.java:426)
at com.android.org.conscrypt.ConscryptEngineSocket$SSLOutputStream.writeInternal(ConscryptEngineSocket.java:657)
at com.android.org.conscrypt.ConscryptEngineSocket$SSLOutputStream.write(ConscryptEngineSocket.java:652)
at okio.OutputStreamSink.write(JvmOkio.kt:56)
at okio.AsyncTimeout$sink$1.write(AsyncTimeout.kt:127)
at okio.RealBufferedSink.flush(RealBufferedSink.kt:268)
at okhttp3.internal.http2.Http2Writer.rstStream(Http2Writer.kt:144)
at okhttp3.internal.http2.Http2Connection.writeSynReset$okhttp(Http2Connection.kt:357)
at okhttp3.internal.http2.Http2Stream.close(Http2Stream.kt:258)
at okhttp3.internal.http2.Http2Stream.cancelStreamIfNecessary$okhttp(Http2Stream.kt:557)
at okhttp3.internal.http2.Http2Stream$FramingSource.close(Http2Stream.kt:539)
at okio.ForwardingSource.close(ForwardingSource.kt:32)
at okhttp3.internal.connection.Exchange$ResponseBodySource.close(Exchange.kt:324)
at okio.RealBufferedSource.close(RealBufferedSource.kt:484)
at aws.smithy.kotlin.runtime.http.engine.okhttp.InstrumentedSource.close(MetricsInterceptor.kt:94)
at okio.RealBufferedSource.close(RealBufferedSource.kt:484)
at okhttp3.internal._UtilCommonKt.closeQuietly(-UtilCommon.kt:302)
at okhttp3.internal._ResponseBodyCommonKt.commonClose(-ResponseBodyCommon.kt:50)
at okhttp3.ResponseBody.close(ResponseBody.kt:181)
at aws.smithy.kotlin.runtime.http.engine.okhttp.OkHttpEngine$roundTrip$2$1.invoke(OkHttpEngine.kt:67)
at aws.smithy.kotlin.runtime.http.engine.okhttp.OkHttpEngine$roundTrip$2$1.invoke(OkHttpEngine.kt:62)
at kotlinx.coroutines.InternalCompletionHandler$UserSupplied.invoke(CompletionHandler.common.kt:67)
at kotlinx.coroutines.InvokeOnCompletion.invoke(JobSupport.kt:1392)
at kotlinx.coroutines.JobSupport.notifyCompletion(JobSupport.kt:1502)
at kotlinx.coroutines.JobSupport.completeStateFinalization(JobSupport.kt:322)
at kotlinx.coroutines.JobSupport.finalizeFinishingState(JobSupport.kt:239)
at kotlinx.coroutines.JobSupport.tryMakeCompletingSlowPath(JobSupport.kt:917)
at kotlinx.coroutines.JobSupport.tryMakeCompleting(JobSupport.kt:874)
at kotlinx.coroutines.JobSupport.cancelMakeCompleting(JobSupport.kt:707)
at kotlinx.coroutines.JobSupport.cancelImpl$kotlinx_coroutines_core(JobSupport.kt:678)
at kotlinx.coroutines.JobSupport.cancelInternal(JobSupport.kt:643)
at kotlinx.coroutines.JobSupport.cancel(JobSupport.kt:628)
at aws.smithy.kotlin.runtime.http.engine.CoroutineUtilsKt$attachToOuterJob$cleanupHandler$1.invoke(CoroutineUtils.kt:51)
at aws.smithy.kotlin.runtime.http.engine.CoroutineUtilsKt$attachToOuterJob$cleanupHandler$1.invoke(CoroutineUtils.kt:49)
at kotlinx.coroutines.InternalCompletionHandler$UserSupplied.invoke(CompletionHandler.common.kt:67)
at kotlinx.coroutines.InvokeOnCancelling.invoke(JobSupport.kt:1438)
at kotlinx.coroutines.JobSupport.notifyCancelling(JobSupport.kt:1483)
at kotlinx.coroutines.JobSupport.tryMakeCancelling(JobSupport.kt:806)
at kotlinx.coroutines.JobSupport.makeCancelling(JobSupport.kt:766)
at kotlinx.coroutines.JobSupport.cancelImpl$kotlinx_coroutines_core(JobSupport.kt:682)
at kotlinx.coroutines.JobSupport.parentCancelled(JobSupport.kt:648)
at kotlinx.coroutines.ChildHandleNode.invoke(JobSupport.kt:1446)
at kotlinx.coroutines.JobSupport.notifyCancelling(JobSupport.kt:1483)
at kotlinx.coroutines.JobSupport.tryMakeCancelling(JobSupport.kt:806)
at kotlinx.coroutines.JobSupport.makeCancelling(JobSupport.kt:766)
at kotlinx.coroutines.JobSupport.cancelImpl$kotlinx_coroutines_core(JobSupport.kt:682)
at kotlinx.coroutines.JobSupport.parentCancelled(JobSupport.kt:648)
at kotlinx.coroutines.ChildHandleNode.invoke(JobSupport.kt:1446)
at kotlinx.coroutines.JobSupport.notifyCancelling(JobSupport.kt:1483)
at kotlinx.coroutines.JobSupport.tryMakeCancelling(JobSupport.kt:806)
at kotlinx.coroutines.JobSupport.makeCancelling(JobSupport.kt:766)
at kotlinx.coroutines.JobSupport.cancelImpl$kotlinx_coroutines_core(JobSupport.kt:682)
at kotlinx.coroutines.JobSupport.parentCancelled(JobSupport.kt:648)
at kotlinx.coroutines.ChildHandleNode.invoke(JobSupport.kt:1446)
at kotlinx.coroutines.JobSupport.notifyCancelling(JobSupport.kt:1483)
at kotlinx.coroutines.JobSupport.tryMakeCancelling(JobSupport.kt:806)
at kotlinx.coroutines.JobSupport.makeCancelling(JobSupport.kt:766)
at kotlinx.coroutines.JobSupport.cancelImpl$kotlinx_coroutines_core(JobSupport.kt:682)
at kotlinx.coroutines.JobSupport.parentCancelled(JobSupport.kt:648)
at kotlinx.coroutines.ChildHandleNode.invoke(JobSupport.kt:1446)
at kotlinx.coroutines.JobSupport.notifyCancelling(JobSupport.kt:1483)
at kotlinx.coroutines.JobSupport.tryMakeCancelling(JobSupport.kt:806)
at kotlinx.coroutines.JobSupport.makeCancelling(JobSupport.kt:766)
at kotlinx.coroutines.JobSupport.cancelImpl$kotlinx_coroutines_core(JobSupport.kt:682)
at kotlinx.coroutines.JobSupport.cancelInternal(JobSupport.kt:643)
at kotlinx.coroutines.JobSupport.cancel(JobSupport.kt:628)
at kotlinx.coroutines.Job$DefaultImpls.cancel$default(Job.kt:195)
Possible Solution
We could not be able to reproduce on our end using the same build that user have
Context
It cause crashing many user devices on the production and need to fix as soon as possible
AWS SDK for Kotlin version
software.amazon.location:auth:0.2.5
aws.sdk.kotlin:location:1.2.38
(Can't update to the latest version due to #1411)
Platform (JVM/JS/Native)
JVM (Kotlin) JDK 17
Operating system and version
Android 13