Closed Bug 786573 Opened 7 years ago Closed 7 years ago

Sensor thread is hanging on shutdown


(Core :: Hardware Abstraction Layer (HAL), defect)

Gonk (Firefox OS)
Not set





(Reporter: cjones, Assigned: cjones)




(1 file)

The problem here is that the android SensorDevice, which wraps the various sensor HALs, sits in its own native poll() loop.  However, the thread on which this runs is an nsIThread, so nsThreadManager will merrily come along and try to join it during XPCOM shutdown.  But since the shutdown notification doesn't interrupt the native poll(), the sensor thread hangs forever.

We've investigated simple hypotheses.  I noticed that we kept a devicelight listener alive much longer than we were supposed to.  Removing this still resulted in a hang.  We also were signalling the sensor thread about added/removed events in what appeared to be the wrong way, but attempting to fix that didn't change anything either.

I think the best solution here is just to use a chromium thread for this.  We need to post events back/forth with the thread so bare pthread isn't quite powerful enough.
bent, the hal stuff here is mostly irrelevant in this patch --- this is just a straight replacement of XPCOM threading with chromium.
Assignee: nobody → jones.chris.g
Attachment #656355 - Flags: review?(bent.mozilla)
Comment on attachment 656355 [details] [diff] [review]
The XPCOM thread manager can't shut down the sensor thread, so use one of our other various thread types for the sensor thread

Review of attachment 656355 [details] [diff] [review]:

Looks good!

::: hal/gonk/GonkSensor.cpp
@@ +208,5 @@
> +
> +  MOZ_ASSERT(sSensorStatus[index].count || aActivate);
> +
> +  SensorDevice& device = SensorDevice::getInstance();
> +      

Nit: whitespace
Attachment #656355 - Flags: review?(bent.mozilla) → review+
Duplicate of this bug: 784079
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla18
You need to log in before you can comment on or make changes to this bug.