You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
See #34 – it's almost the same problem, but on Android the app is still responsive, the native thread is blocked, though.
As a result, only one subscribe authorizer can be fired at the same time, because the first call will lock the mutex (and the thread).
The next one has to wait until the first one completes and if it does not complete (unlock the mutex) then the authorization logic is completely blocked.
The possible fix is the same as on iOS – remove the logic that relies on mutex in favor of a more lightweight blocking mechanism (like this) and a timeout in case JS does never return the auth object for a given subscription.
Repro steps:
Install example app from this pusher repo on Android, commit b65a2c5fd885a2be4b1e9d1cbf9e8f5183622ef5
Simulate multiple subscriptions fired at the same time:
Add this in connect:
awaitpusher.connect();awaitpusher.subscribe({ channelName });// add the lines below to fire extra subscriptionssetTimeout(async()=>{awaitpusher.subscribe({channelName: channelName+'_1'});},100);setTimeout(async()=>{awaitpusher.subscribe({channelName: channelName+'_2'});},100);
Add this in onAuthorizer:
constonAuthorizer=async(channelName: string,socketId: string)=>{// this could also be await fetch(url), but long timeout is better for reproconsole.warn('start '+channelName);awaitnewPromise((resolve)=>setTimeout(resolve,5000));console.warn('end '+channelName);
Start the app, fill in Pusher text inputs (remember to use private- channel prefix to trigger auth!)
Tap Connect button and check the logs (console.warns)
Expectation: We should first see 3x start log and then 3x end log
Actual: It runs sequentially – first one start, then end+start and so it goes
FWIW – it works as expected on iOS here after removing the mutexes
The text was updated successfully, but these errors were encountered:
Problem
See #34 – it's almost the same problem, but on Android the app is still responsive, the native thread is blocked, though.
As a result, only one
subscribe
authorizer can be fired at the same time, because the first call will lock the mutex (and the thread).The next one has to wait until the first one completes and if it does not complete (unlock the mutex) then the authorization logic is completely blocked.
The possible fix is the same as on iOS – remove the logic that relies on mutex in favor of a more lightweight blocking mechanism (like this) and a timeout in case JS does never return the auth object for a given subscription.
Repro steps:
b65a2c5fd885a2be4b1e9d1cbf9e8f5183622ef5
Add this in
connect
:Add this in
onAuthorizer
:private-
channel prefix to trigger auth!)console.warn
s)Expectation: We should first see 3x
start
log and then 3xend
logActual: It runs sequentially – first one start, then end+start and so it goes
FWIW – it works as expected on iOS here after removing the mutexes
The text was updated successfully, but these errors were encountered: