Make sure the network process always resumes its database threads when coming out of suspension, even if the main thread is hung.
<rdar://problem/62463389>
Created attachment 397839 [details] Patch
Created attachment 397843 [details] Patch
What are the cases where main thread is blocked by a suspended database thread? Doesn't main thread know database threads' state? Or we probably should not block main thread on a database thread at all?
(In reply to Sihui Liu from comment #4) > What are the cases where main thread is blocked by a suspended database > thread? Doesn't main thread know database threads' state? > > Or we probably should not block main thread on a database thread at all? Well, we probably should not but it happens. See rdar://problem/62377357 for one example.
(In reply to Chris Dumez from comment #5) > (In reply to Sihui Liu from comment #4) > > What are the cases where main thread is blocked by a suspended database > > thread? Doesn't main thread know database threads' state? > > > > Or we probably should not block main thread on a database thread at all? > > Well, we probably should not but it happens. See rdar://problem/62377357 for > one example. Alex fixed the case in rdar://problem/62377357 but it is not the first time we have radars about similar issues so I thought we should tweak the design to make sure it does not happen again.
(In reply to Chris Dumez from comment #6) > (In reply to Chris Dumez from comment #5) > > (In reply to Sihui Liu from comment #4) > > > What are the cases where main thread is blocked by a suspended database > > > thread? Doesn't main thread know database threads' state? > > > > > > Or we probably should not block main thread on a database thread at all? > > > > Well, we probably should not but it happens. See rdar://problem/62377357 for > > one example. > > Alex fixed the case in rdar://problem/62377357 but it is not the first time > we have radars about similar issues so I thought we should tweak the design > to make sure it does not happen again. I see. Looks like we can apply Alex's fix to all the cases where main thread is blocked on a database thread(I currently see ~StorageManagerSet() and waitUntilSyncingLocalStorageFinished()). It might be worthwhile to get those fixed and make sure network process not wait especially when it's suspended(m_suspended is true). Your fix will solve most hang issues on suspension, but it covers those blocking on main thread issues and relies on ProcessTaskStateObserver to do the right thing and adds another thread(?).
We’ve gotten rid of all cases of hangs of the NetworkProcess main thread on database threads. Let’s see if this is sufficient before doing this change, given that it adds complexity.