Closed Bug 1211035 Opened 9 years ago Closed 4 years ago

Keep service workers alive while debugging

Categories

(DevTools :: Debugger, enhancement, P5)

enhancement

Tracking

(Not tracked)

RESOLVED WORKSFORME

People

(Reporter: akratel, Unassigned)

References

(Blocks 2 open bugs)

Details

(Whiteboard: [debugger-reserve])

When a service worker is being inspected and debugged, it should be kept alive, i.e. the system should not be able to take the SW out of memory when it's idle. 

From about:debugging, if a developer selects a SW for debugging, it should be kept alive for the length of the debugging session, unless the developer forces the close of the SW from about:debugging.
According to Ehsan, there are no additional APIs required to do this, these must already exist. Please check back with Ehsan or Eddy for info on how to do this. 

The SW should be kept alive from: 

1) when opened for debugging from about:debugging
2) When selected and opened from the debugger while the main scope tab is debugged, i.e. when debugging the page/tab that loads the SW to begin with.
(In reply to Axel Kratel from comment #1)
> According to Ehsan, there are no additional APIs required to do this, these
> must already exist. Please check back with Ehsan or Eddy for info on how to
> do this. 
> 
> The SW should be kept alive from: 
> 
> 1) when opened for debugging from about:debugging
> 2) When selected and opened from the debugger while the main scope tab is
> debugged, i.e. when debugging the page/tab that loads the SW to begin with.

Eddy, can you confirm that you have an idea of how to accomplish this?  I'm happy to help if I can - let's chat further next week about it.
Flags: needinfo?(ejpbruel)
(In reply to Brian Grinstead [:bgrins] from comment #2)
> (In reply to Axel Kratel from comment #1)
> > According to Ehsan, there are no additional APIs required to do this, these
> > must already exist. Please check back with Ehsan or Eddy for info on how to
> > do this. 
> > 
> > The SW should be kept alive from: 
> > 
> > 1) when opened for debugging from about:debugging
> > 2) When selected and opened from the debugger while the main scope tab is
> > debugged, i.e. when debugging the page/tab that loads the SW to begin with.
> 
> Eddy, can you confirm that you have an idea of how to accomplish this?  I'm
> happy to help if I can - let's chat further next week about it.

The feature Ehsan is referring to is called a WorkerFeature. Any API can add itself (or another object) as a WorkerFeature to a WorkerPrivate (which represents the worker). As long as there are any WorkerFeatures left, the WorkerPrivate cannot be destroyed.

ServiceWorker uses a WorkerPrivate for its underlying worker. My understanding is that even if ServiceWorker drops its WorkerPrivate (because there are no events to be processed) this WorkerPrivate can be reused if it is still alive then the ServiceWorker reactivates. As a result, if we can keep the WorkerPrivate alive, that should give use exactly the behavior we need.

The basic idea is thus to have the debugger add a WorkerFeature for the duration that it needs to keep the worker alive. The only thing I haven't figured out yet are details such as whether this needs to be done by the platform API internally, or by the debugger server using methods provided by the platform API, and whether we need to do this on the main thread or inside the worker thread itself.
Flags: needinfo?(ejpbruel)
Product: Firefox → DevTools
Blocks: dbg-worker
Type: defect → enhancement
Priority: -- → P5
Blocks: dbg-71
Whiteboard: [debugger-mvp]
Whiteboard: [debugger-mvp] → [debugger-reserve]

Harald, this should be already fixed. Is there a dup somewhere?

Honza

Flags: needinfo?(hkirschner)

Bug 1596934 seems related, but mentions WorkerTargetFront's logic for preventing worker shutdown; so the original work landed before that. I think this can be closed.

Flags: needinfo?(hkirschner)
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.