ServiceWorkerContext(Wrapper) seems to be inconsistent as to which thread callbacks are called on. |
|||||||
Issue descriptionMost methods on ServiceWorkerContextWrapper can only be called from the IO thread, and also call their callbacks from the IO thread. There are a few odd methods though that can be called from any thread (and internally postTask to end up on the IO thread), and these methods are very inconsistent as to on which thread they call their callbacks. Some do it on the IO thread, some on the UI thread, and for some it even depends on the result of the operation (even for methods like CheckHasServiceWorker which is documented as always calling its callback on the UI thread it sometimes calls it callback on the IO thread). I propose to fix this mess by making all these weird sort-of-thread-safe methods be only allowed to be called on the IO thread (like the majority of the methods in the class already are), and to then always call their callbacks on the IO thread as well. Having clear/easy to understand behavior seems way preferred over the current undocumented and seemingly random threading behavior.
,
Mar 2 2016
Documented at least the current behavior (after fixing the two methods that sometimes call their callback on the IO thread and sometimes on the UI thread) in https://codereview.chromium.org/1757023003 I still think getting some more consistency would be nice, but at least with comments people don't have to dig through the implementation to figure out on which thread a method can be called and on which thread they should expect their callback to be called...
,
Mar 3 2016
Yes, this has come up previously: https://codereview.chromium.org/893793005 and https://codereview.chromium.org/761923004/ and https://groups.google.com/a/chromium.org/forum/#!msg/chromium-dev/uWGNk-hVlGc/M92wu3izhGEJ I think SWContextWrapper was originally intended to be threadsafe but agree it's gotten inconsistent and confusing the threads each function is entered on and calls back on. I'd support requiring everything on the IO thread as you propose above.
,
Mar 3 2016
SWContextWrapper was originally for two things - implement the content public ServiceWorkerContext api, provide the entry points for those methods (some of which were intended to be only UI thread invocable). - bridge the gap between the UI thread StoragePartition object and its indirect ownership of the IO thread SwContextCore object. Over time, methods got added "for convenience". Might be cleaner to remove the convenience methods and provide a public context_core() getter that's only callable from the IO thread.
,
Mar 4 2016
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/e51e01d8b2c430f2f327692e2b98006b8dc0763d commit e51e01d8b2c430f2f327692e2b98006b8dc0763d Author: mek <mek@chromium.org> Date: Fri Mar 04 00:05:45 2016 Document confusing threading requirements in ServiceWorkerContext(Wrapper). This adds comments to all public methods in ServiceWorkerContext and ServiceWorkerContextWrapper explaining on which thread the method can be called, and on which thread its callback will be called. Also fixes some inconsistencies where for some methods a callback could be sometimes called on different threads. BUG=591427 Review URL: https://codereview.chromium.org/1757023003 Cr-Commit-Position: refs/heads/master@{#379145} [modify] https://crrev.com/e51e01d8b2c430f2f327692e2b98006b8dc0763d/content/browser/service_worker/service_worker_context_wrapper.cc [modify] https://crrev.com/e51e01d8b2c430f2f327692e2b98006b8dc0763d/content/browser/service_worker/service_worker_context_wrapper.h [modify] https://crrev.com/e51e01d8b2c430f2f327692e2b98006b8dc0763d/content/public/browser/service_worker_context.h
,
Dec 9 2016
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/347362dc1067fdee8a0b512bf24659ae5b8dced6 commit 347362dc1067fdee8a0b512bf24659ae5b8dced6 Author: droger <droger@chromium.org> Date: Fri Dec 09 14:16:06 2016 CheckHasServiceWorkerCallback always called on the UI thread This updates the code to match the documentation in service_worker_context.h. BUG=591427 Review-Url: https://codereview.chromium.org/2566623004 Cr-Commit-Position: refs/heads/master@{#437531} [modify] https://crrev.com/347362dc1067fdee8a0b512bf24659ae5b8dced6/content/browser/service_worker/service_worker_context_wrapper.cc
,
Dec 11 2017
This issue has been Available for over a year. If it's no longer important or seems unlikely to be fixed, please consider closing it out. If it is important, please re-triage the issue. Sorry for the inconvenience if the bug really should have been left as Available. If you change it back, also remove the "Hotlist-Recharge-Cold" label. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Dec 15 2017
,
Dec 15 2017
,
Dec 17
This issue has been Available for over a year. If it's no longer important or seems unlikely to be fixed, please consider closing it out. If it is important, please re-triage the issue. Sorry for the inconvenience if the bug really should have been left as Available. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Dec 18
This is timely given https://chromium-review.googlesource.com/c/chromium/src/+/1344136. Putting back on the shelf but it'd be nice to bring consistency to this API, probably by requiring functions to be called on a specific thread. |
|||||||
►
Sign in to add a comment |
|||||||
Comment 1 by mek@chromium.org
, Mar 2 2016