New issue
Advanced search Search tips

Issue 876207 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Aug 28
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug

Blocking:
issue 721147



Sign in to add a comment

Extension Service Worker events: keep worker alive during event dispatch

Project Member Reported by lazyboy@chromium.org, Aug 21

Issue description

Lazy background pages increment lazy keep alive counts through EventRouter::IncrementInFlightEvents, we need similar idea for extension service worker for event dispatch.

//content already exposes ability to inc/dec ref-count of a worker through SWContext::Starting/FinishedExternalRequest. This is available on IO thread. EventRouter needs to hook into it for extension SW events.
 
Project Member

Comment 1 by bugdroid1@chromium.org, Aug 25

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/a14ec485e712f2ae5fcf4c92ca6f3d2d30da2343

commit a14ec485e712f2ae5fcf4c92ca6f3d2d30da2343
Author: Istiaque Ahmed <lazyboy@chromium.org>
Date: Sat Aug 25 01:02:18 2018

[Extension SW] Add ref count during event dispatch.

This CL adds ref count to a ServiceWorker while dispatching an
extension event to it. The ref count is decreased when we receive an
ack for worker thread, similar to vanilla extension events.

This CL adds the event ack IPC from worker thread to browser process.

The ref counting methods in //content (Starting/FinishedExternalRequest)
requires service worker version id within a SWContext, this CL adds
support for this:
  - in browser process: EventListeners now also include service
    worker version id.
  - in browser process: ServiceWorkerContext::StartWorkerForPattern
    returns version id along with existing information (render process
    id and worker thread id). ServiceWorkerTaskQueue uses it to
    dispatch event through EventRouter.
  - in worker thread: ScriptContext of a worker also stores the
    version id, used while sending event ack from WorkerThreadDispatcher.

Bug:  876207 
Change-Id: Ia0d2df39091ac07504444523020fef9579e42696
Reviewed-on: https://chromium-review.googlesource.com/1175420
Commit-Queue: Istiaque Ahmed <lazyboy@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Matt Falkenhagen <falken@chromium.org>
Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
Reviewed-by: Devlin <rdevlin.cronin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#586087}
[modify] https://crrev.com/a14ec485e712f2ae5fcf4c92ca6f3d2d30da2343/chrome/browser/extensions/service_worker_apitest.cc
[add] https://crrev.com/a14ec485e712f2ae5fcf4c92ca6f3d2d30da2343/chrome/test/data/extensions/api_test/service_worker/worker_based_background/early_filtered_event_dispatch/manifest.json
[add] https://crrev.com/a14ec485e712f2ae5fcf4c92ca6f3d2d30da2343/chrome/test/data/extensions/api_test/service_worker/worker_based_background/early_filtered_event_dispatch/service_worker_background.js
[modify] https://crrev.com/a14ec485e712f2ae5fcf4c92ca6f3d2d30da2343/content/browser/service_worker/service_worker_context_wrapper.cc
[modify] https://crrev.com/a14ec485e712f2ae5fcf4c92ca6f3d2d30da2343/content/public/browser/service_worker_context.h
[modify] https://crrev.com/a14ec485e712f2ae5fcf4c92ca6f3d2d30da2343/extensions/browser/BUILD.gn
[modify] https://crrev.com/a14ec485e712f2ae5fcf4c92ca6f3d2d30da2343/extensions/browser/bad_message.h
[modify] https://crrev.com/a14ec485e712f2ae5fcf4c92ca6f3d2d30da2343/extensions/browser/event_listener_map.cc
[modify] https://crrev.com/a14ec485e712f2ae5fcf4c92ca6f3d2d30da2343/extensions/browser/event_listener_map.h
[modify] https://crrev.com/a14ec485e712f2ae5fcf4c92ca6f3d2d30da2343/extensions/browser/event_router.cc
[modify] https://crrev.com/a14ec485e712f2ae5fcf4c92ca6f3d2d30da2343/extensions/browser/event_router.h
[add] https://crrev.com/a14ec485e712f2ae5fcf4c92ca6f3d2d30da2343/extensions/browser/events/event_ack_data.cc
[add] https://crrev.com/a14ec485e712f2ae5fcf4c92ca6f3d2d30da2343/extensions/browser/events/event_ack_data.h
[modify] https://crrev.com/a14ec485e712f2ae5fcf4c92ca6f3d2d30da2343/extensions/browser/extension_message_filter.cc
[modify] https://crrev.com/a14ec485e712f2ae5fcf4c92ca6f3d2d30da2343/extensions/browser/extension_message_filter.h
[modify] https://crrev.com/a14ec485e712f2ae5fcf4c92ca6f3d2d30da2343/extensions/browser/extension_service_worker_message_filter.cc
[modify] https://crrev.com/a14ec485e712f2ae5fcf4c92ca6f3d2d30da2343/extensions/browser/extension_service_worker_message_filter.h
[modify] https://crrev.com/a14ec485e712f2ae5fcf4c92ca6f3d2d30da2343/extensions/browser/lazy_background_task_queue.cc
[modify] https://crrev.com/a14ec485e712f2ae5fcf4c92ca6f3d2d30da2343/extensions/browser/lazy_context_task_queue.h
[modify] https://crrev.com/a14ec485e712f2ae5fcf4c92ca6f3d2d30da2343/extensions/browser/service_worker_task_queue.cc
[modify] https://crrev.com/a14ec485e712f2ae5fcf4c92ca6f3d2d30da2343/extensions/common/extension_messages.h
[modify] https://crrev.com/a14ec485e712f2ae5fcf4c92ca6f3d2d30da2343/extensions/renderer/dispatcher.cc
[modify] https://crrev.com/a14ec485e712f2ae5fcf4c92ca6f3d2d30da2343/extensions/renderer/ipc_message_sender.cc
[modify] https://crrev.com/a14ec485e712f2ae5fcf4c92ca6f3d2d30da2343/extensions/renderer/script_context.cc
[modify] https://crrev.com/a14ec485e712f2ae5fcf4c92ca6f3d2d30da2343/extensions/renderer/script_context.h
[modify] https://crrev.com/a14ec485e712f2ae5fcf4c92ca6f3d2d30da2343/extensions/renderer/worker_thread_dispatcher.cc
[modify] https://crrev.com/a14ec485e712f2ae5fcf4c92ca6f3d2d30da2343/tools/metrics/histograms/enums.xml

Status: Fixed (was: Started)

Sign in to add a comment