Summary
GraphQL queries are taking a huge amount of time (~2 minutes) on some Android devices.
Version
Using apollo 2.4.1 but was also happening on 1.4.5 (did the migration in an attempt to fix it)
Description
I know this is a rather generic issue, what tools could I use to debug/test this so I can find exactly where the issue is?
I've tried to remove every possible dependency in the project to the minimum code:
val client = ApolloClient.builder()
.serverUrl("https://myserver/graphql")
.build()
val apolloCall = client.query(PeriodQuery.builder().build())
val response = apolloCall.await()
// At this point it stays suspended for 2 minutes on some devices
// ...
val featuredItems = response.data?.period()?.Period()?.features()
Sharing the query in case it helps (though it also happens with other queries)
query
query Period {
period {
Period {
_id
year
week
numberOfFeatures
features {
_id
type
name
editorialTitle
editorialContent
suppressName
suppressHeader
teaser {
x
xx
xxx
xxxx
svg
}
teaserCopyright
issueId
articleSeriesId
articleIds
issue {
_id
accessible
purchased
downloadable
designation
coverStory
brandId
cover {
x
xx
xxx
xxxx
svg
}
}
articleSeries {
_id
name
description
teaser {
x
xx
xxx
xxxx
}
teaserCopyright
brandIds
authorIds
articles {
_id
}
}
articles {
_id
accessible
read
type
name
subtitle
brandId
issueId
articleSeriesId
articleSeriesOrder
teaserImage {
x
xx
xxx
xxxx
}
teaserCopyright
issue {
id: _id
accessible
purchased
downloadable
designation
brandId
thumbnailSmall {
x
xx
xxx
xxxx
svg
}
cover {
x
xx
xxx
xxxx
svg
}
year
month
}
}
}
}
}
}
Hi! Thanks for sending this.
The first thing would be to determine whether the slowdown happens on the server or on the client. Can you hook a proxy or a HttpInterceptor to measure the network time? Maybe it's something in the query that takes longer on the server side.
If it's happening client side, (which is more likely given that it happens only on specific devices), the best way to investigate is to do some profiling. If you can generate a .trace file using Debug.startMethodTracing("apollo") and Debug.stopMethodTracing() and share it, that will give us some clues. See https://developer.android.com/studio/profile/generate-trace-logs for a guide on how to do profiling on Android.
Also feel free to use the email address associated with my commits if you don't want to share that publicly.
Hi @Alqueraf ! Any news from this? Anything else I can help with? If not I'll close this issue in the coming days.
Hi Martin, the instructions were great, thanks! I haven't had a chance to follow it through yet, will do in the following days 馃檹
Hi, just sent you all the details over email.
After removing the apollo library it is still occurring so this is actually related to the OkHttp client.
Closing the issue and thanks for your help!
Thanks for the follow up!