PhoneGap navigator.compass.watchHeading freezes on iPhone after some time.

60 views
Skip to first unread message

ma...@leegte.org

unread,
Jul 28, 2015, 5:16:29 PM7/28/15
to phonegap

I'm running a three.js phonegap project on a iPhone 5s, which rotates the camera according to the compass heading readout.

All works as it should, but for the freezing of the compass readout after 10 seconds. The app continues to work fine, but the function rotateCameraWithCompass isn't called anymore. Also there is no call to compassError. The watchHeading method seems to have frozen.


function rotateCameraWithCompass( heading ) {
    camera.rotation.y = -1 * Math.toRad( heading.magneticHeading );
}

function compassError( compassError ) { console.log( 'Compass error: ' + compassError.code ); }

var watchID = navigator.compass.watchHeading( rotateCameraWithCompass, compassError, { frequency: 30 } );


I lowered the frequency down to from 30 ms to 100ms, but it still freezes after about 10 seconds. It seems such a light request, so I can't imagine why if freezes.


Can the watchHeading method be used for continuous live AR camera rotating? If not, does that mean that AR on PhoneGap iOS is impossible?

Jesse Monroy

unread,
Jul 28, 2015, 6:35:44 PM7/28/15
to phonegap, ma...@leegte.org
@ma,
I have demo apps for compass, but not iOS - as my test device is iPod Touch, which has no compass.

Even so, iOS has quirks noted in the documention:

Only one watchHeading can be in effect at one time in iOS. If a watchHeading uses a filter, calling getCurrentHeading or watchHeading uses the existing filter value to specify heading changes. Watching heading changes with a filter is more efficient than with time intervals.

http://docs.phonegap.com/en/4.0.0/cordova_plugins_pluginapis.md.html#Plugin%20APIs
http://plugins.cordova.io/#/package/org.apache.cordova.device-orientation

There more quirks for iOS listed.

Jesse

jcesarmobile

unread,
Jul 29, 2015, 2:13:00 AM7/29/15
to phonegap, ma...@leegte.org
If something is not working as you expect, file an issue on the issues page giving all the details you can (cordova version, plugin version, device you tested, OS of the device you tested, etc)
http://issues.cordova.io/
Reply all
Reply to author
Forward
0 new messages