Neal Sanche
05/06/2021, 5:32 PMmbonnin
05/11/2021, 8:49 AMdev-3.x
but I just added a subscription test that makes K/N subscriptions against the tutorial server: https://github.com/apollographql/apollo-android/pull/3102/files#diff-93890a9196f59ee3f458c788b6039f0c6e7fd0a3021fe5d3f43ccbf56537e88eNeal Sanche
05/11/2021, 5:10 PMrunWithMainLoop
sections in the tests are likely why they work. I'm going to work on a super small sample that shows the problems that I'm having with this. I either get illegal dereference, or the frozen access exceptions and I have no idea why this would be happening when the non subscription (mutations and queries) code works fine. I'm definitely missing something.mbonnin
05/11/2021, 5:11 PMcoroutines-mt
that might the issueNeal Sanche
05/11/2021, 5:13 PMcoroutines-mt
but it works for queries and mutations. The difference I guess is the web socket setup.mbonnin
05/11/2021, 5:22 PMApolloWebSocketNetworkTransport
from something else than the main thread?Neal Sanche
05/11/2021, 5:42 PMException doesn't match @Throws-specified class list and thus isn't propagated from Kotlin to Objective-C/Swift as NSError.
It is considered unexpected and unhandled instead. Program will be terminated.
Uncaught Kotlin exception: kotlin.native.concurrent.FreezingException: freezing of Ok(result=<no name provided>_1@23ff648) has failed, first blocker is com.apollographql.apollo.network.ws.ApolloWebSocketNetworkTransport@b4288
mbonnin
05/11/2021, 5:44 PMNeal Sanche
05/11/2021, 5:47 PMmbonnin
05/11/2021, 5:51 PMIsolateState
for providedValues
as all this code should run from the main threadMainLoopDispatcher
as from the samples? https://github.com/apollographql/apollo-android/blob/b4b7c9a0816c7e6491d026ed216cb[…]n/com/apollographql/apollo/kmpsample/data/MainLoopDispatcher.ktNeal Sanche
05/11/2021, 6:05 PMmbonnin
05/11/2021, 6:07 PMcoroutines-mt
provide Dispatchers.Main
?Neal Sanche
05/11/2021, 6:15 PMcoroutines-mt
and flowOn(Dispatchers.Main)
. I seem to be able to make a flow in place, and those elements get delivered to iOS as expected, but as soon as I replace the flow with an Apollo subscription, I get the frozen errors.mbonnin
05/11/2021, 6:20 PMactual val myMainDispatcher = MainLoopDispatcher
on iOS and use Dispatchers.Main on AndroidNeal Sanche
05/11/2021, 6:23 PMinvokeOnTimeout
has a different method signature now. Using 1.4.3-mt.mbonnin
05/11/2021, 6:24 PMimmediate
modedispatch_async(dispatch_get_main_queue()) {
block.run()
}
Neal Sanche
05/11/2021, 6:31 PM@InternalCoroutinesApi
all over the place to get it compiling.mbonnin
05/11/2021, 6:33 PMNeal Sanche
05/11/2021, 6:34 PMmbonnin
05/11/2021, 6:35 PMNeal Sanche
05/11/2021, 6:38 PMmbonnin
05/11/2021, 6:40 PMBearerTokenInterceptor
being an ApolloRequestInterceptor
, will also get called from the main loopNeal Sanche
05/11/2021, 6:40 PMmbonnin
05/11/2021, 6:40 PMsuspend fun intercept
which is where you'd do the "async part" because you don't want to block the main thread thereNeal Sanche
05/11/2021, 6:45 PMmbonnin
05/11/2021, 6:45 PMNeal Sanche
05/11/2021, 6:45 PMmbonnin
05/11/2021, 6:46 PMIsolateState
Neal Sanche
05/11/2021, 6:48 PMmbonnin
05/11/2021, 6:50 PMsingleton objects unless marked with @kotlin.native.ThreadLocal are frozen and shared, lazy values allowed, unless cyclic frozen structures were attempted to be created
providedValues.access {
it.put(TOKEN_PROVIDER, provider)
it.put(APOLLO_CLIENT, makeApolloClient())
}
IIRC, IsolateState
will run the access {}
block in its own isolated workerApolloClient
is created from a background threadNeal Sanche
05/11/2021, 6:53 PMmbonnin
05/11/2021, 6:54 PMval apolloClient: ApolloClient
get() = providedValues.access {
it[APOLLO_CLIENT] as ApolloClient
}
freezes the clientNeal Sanche
05/11/2021, 6:54 PMmbonnin
05/11/2021, 6:55 PMNeal Sanche
05/11/2021, 6:55 PMmbonnin
05/11/2021, 6:55 PMNeal Sanche
05/11/2021, 6:56 PMmbonnin
05/11/2021, 6:58 PMNeal Sanche
05/11/2021, 6:59 PM