⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 259601 in webkit


Ignore:
Timestamp:
Apr 6, 2020, 4:05:15 PM (6 years ago)
Author:
Alan Coon
Message:

Cherry-pick r259315. rdar://problem/61352448

Regression(r253357) DeviceMotionEvent acceleration and rotationRate are null
https://bugs.webkit.org/show_bug.cgi?id=209831
<rdar://problem/60720953>

Reviewed by Darin Adler.

Source/WebCore:

The issue was that DeviceMotionClientIOS::motionChanged() would only initialize the
acceleration and rotationRate if [m_motionManager gyroAvailable] returned YES. After
r253357, m_motionManager is nil because we get motion data from the UIProcess so
[m_motionManager gyroAvailable] would always resolve to NO.

To address the issue, I made the rotationRate parameters to motionChanged() optional
and we rely on them being set to know if gyro data is available. Note that I did not
make the acceleration optional because according to [1], all devices have an
accelerometer.

[1] https://developer.apple.com/documentation/coremotion/cmmotionmanager/1616094-devicemotionavailable?language=objc

  • platform/ios/DeviceMotionClientIOS.h:
  • platform/ios/DeviceMotionClientIOS.mm: (WebCore::DeviceMotionClientIOS::motionChanged):
  • platform/ios/DeviceOrientationUpdateProvider.h:
  • platform/ios/MotionManagerClient.h: (WebCore::MotionManagerClient::motionChanged):
  • platform/ios/WebCoreMotionManager.mm: (-[WebCoreMotionManager sendAccelerometerData:]):

Source/WebKit:

  • UIProcess/ios/WebDeviceOrientationUpdateProviderProxy.h:
  • UIProcess/ios/WebDeviceOrientationUpdateProviderProxy.mm: (WebKit::WebDeviceOrientationUpdateProviderProxy::motionChanged):
  • WebProcess/WebCoreSupport/WebDeviceOrientationUpdateProvider.cpp: (WebKit::WebDeviceOrientationUpdateProvider::deviceMotionChanged):
  • WebProcess/WebCoreSupport/WebDeviceOrientationUpdateProvider.h:
  • WebProcess/WebCoreSupport/WebDeviceOrientationUpdateProvider.messages.in:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@259315 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Location:
branches/safari-609-branch/Source
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-609-branch/Source/WebCore/ChangeLog

    r259599 r259601  
     12020-04-06  Alan Coon  <alancoon@apple.com>
     2
     3        Cherry-pick r259315. rdar://problem/61352448
     4
     5    Regression(r253357) DeviceMotionEvent acceleration and rotationRate are null
     6    https://bugs.webkit.org/show_bug.cgi?id=209831
     7    <rdar://problem/60720953>
     8   
     9    Reviewed by Darin Adler.
     10   
     11    Source/WebCore:
     12   
     13    The issue was that DeviceMotionClientIOS::motionChanged() would only initialize the
     14    acceleration and rotationRate if [m_motionManager gyroAvailable] returned YES. After
     15    r253357, m_motionManager is nil because we get motion data from the UIProcess so
     16    [m_motionManager gyroAvailable] would always resolve to NO.
     17   
     18    To address the issue, I made the rotationRate parameters to motionChanged() optional
     19    and we rely on them being set to know if gyro data is available. Note that I did not
     20    make the acceleration optional because according to [1], all devices have an
     21    accelerometer.
     22   
     23    [1] https://developer.apple.com/documentation/coremotion/cmmotionmanager/1616094-devicemotionavailable?language=objc
     24   
     25    * platform/ios/DeviceMotionClientIOS.h:
     26    * platform/ios/DeviceMotionClientIOS.mm:
     27    (WebCore::DeviceMotionClientIOS::motionChanged):
     28    * platform/ios/DeviceOrientationUpdateProvider.h:
     29    * platform/ios/MotionManagerClient.h:
     30    (WebCore::MotionManagerClient::motionChanged):
     31    * platform/ios/WebCoreMotionManager.mm:
     32    (-[WebCoreMotionManager sendAccelerometerData:]):
     33   
     34    Source/WebKit:
     35   
     36    * UIProcess/ios/WebDeviceOrientationUpdateProviderProxy.h:
     37    * UIProcess/ios/WebDeviceOrientationUpdateProviderProxy.mm:
     38    (WebKit::WebDeviceOrientationUpdateProviderProxy::motionChanged):
     39    * WebProcess/WebCoreSupport/WebDeviceOrientationUpdateProvider.cpp:
     40    (WebKit::WebDeviceOrientationUpdateProvider::deviceMotionChanged):
     41    * WebProcess/WebCoreSupport/WebDeviceOrientationUpdateProvider.h:
     42    * WebProcess/WebCoreSupport/WebDeviceOrientationUpdateProvider.messages.in:
     43   
     44   
     45    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@259315 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     46
     47    2020-03-31  Chris Dumez  <cdumez@apple.com>
     48
     49            Regression(r253357) DeviceMotionEvent acceleration and rotationRate are null
     50            https://bugs.webkit.org/show_bug.cgi?id=209831
     51            <rdar://problem/60720953>
     52
     53            Reviewed by Darin Adler.
     54
     55            The issue was that DeviceMotionClientIOS::motionChanged() would only initialize the
     56            acceleration and rotationRate if [m_motionManager gyroAvailable] returned YES. After
     57            r253357, m_motionManager is nil because we get motion data from the UIProcess so
     58            [m_motionManager gyroAvailable] would always resolve to NO.
     59
     60            To address the issue, I made the rotationRate parameters to motionChanged() optional
     61            and we rely on them being set to know if gyro data is available. Note that I did not
     62            make the acceleration optional because according to [1], all devices have an
     63            accelerometer.
     64
     65            [1] https://developer.apple.com/documentation/coremotion/cmmotionmanager/1616094-devicemotionavailable?language=objc
     66
     67            * platform/ios/DeviceMotionClientIOS.h:
     68            * platform/ios/DeviceMotionClientIOS.mm:
     69            (WebCore::DeviceMotionClientIOS::motionChanged):
     70            * platform/ios/DeviceOrientationUpdateProvider.h:
     71            * platform/ios/MotionManagerClient.h:
     72            (WebCore::MotionManagerClient::motionChanged):
     73            * platform/ios/WebCoreMotionManager.mm:
     74            (-[WebCoreMotionManager sendAccelerometerData:]):
     75
    1762020-04-06  Alan Coon  <alancoon@apple.com>
    277
  • branches/safari-609-branch/Source/WebCore/platform/ios/DeviceMotionClientIOS.h

    r253357 r259601  
    4949    void deviceMotionControllerDestroyed() override;
    5050
    51     void motionChanged(double, double, double, double, double, double, double, double, double) override;
     51    void motionChanged(double, double, double, double, double, double, Optional<double>, Optional<double>, Optional<double>) override;
    5252
    5353private:
  • branches/safari-609-branch/Source/WebCore/platform/ios/DeviceMotionClientIOS.mm

    r253357 r259601  
    9292}
    9393
    94 void DeviceMotionClientIOS::motionChanged(double xAcceleration, double yAcceleration, double zAcceleration, double xAccelerationIncludingGravity, double yAccelerationIncludingGravity, double zAccelerationIncludingGravity, double xRotationRate, double yRotationRate, double zRotationRate)
     94void DeviceMotionClientIOS::motionChanged(double xAcceleration, double yAcceleration, double zAcceleration, double xAccelerationIncludingGravity, double yAccelerationIncludingGravity, double zAccelerationIncludingGravity, Optional<double> xRotationRate, Optional<double> yRotationRate, Optional<double> zRotationRate)
    9595{
    9696    if (!m_updating)
     
    114114    auto accelerationIncludingGravity = DeviceMotionData::Acceleration::create(xAccelerationIncludingGravity, yAccelerationIncludingGravity, zAccelerationIncludingGravity);
    115115
    116     RefPtr<DeviceMotionData::Acceleration> acceleration;
     116    RefPtr<DeviceMotionData::Acceleration> acceleration = DeviceMotionData::Acceleration::create(xAcceleration, yAcceleration, zAcceleration);
    117117    RefPtr<DeviceMotionData::RotationRate> rotationRate;
    118     if ([m_motionManager gyroAvailable]) {
    119         acceleration = DeviceMotionData::Acceleration::create(xAcceleration, yAcceleration, zAcceleration);
    120         rotationRate = DeviceMotionData::RotationRate::create(xRotationRate, yRotationRate, zRotationRate);
    121     }
     118    // Not all devices have a gyroscope.
     119    if (xRotationRate && yRotationRate && zRotationRate)
     120        rotationRate = DeviceMotionData::RotationRate::create(*xRotationRate, *yRotationRate, *zRotationRate);
    122121#endif // PLATFORM(IOS_FAMILY_SIMULATOR)
    123122
  • branches/safari-609-branch/Source/WebCore/platform/ios/DeviceOrientationUpdateProvider.h

    r253357 r259601  
    4545
    4646    virtual void deviceOrientationChanged(double, double, double, double, double) = 0;
    47     virtual void deviceMotionChanged(double, double, double, double, double, double, double, double, double) = 0;
     47    virtual void deviceMotionChanged(double, double, double, double, double, double, Optional<double>, Optional<double>, Optional<double>) = 0;
    4848   
    4949protected:
  • branches/safari-609-branch/Source/WebCore/platform/ios/MotionManagerClient.h

    r253357 r259601  
    3737
    3838    virtual void orientationChanged(double, double, double, double, double) { }
    39     virtual void motionChanged(double, double, double, double, double, double, double, double, double) { }
     39    virtual void motionChanged(double, double, double, double, double, double, Optional<double>, Optional<double>, Optional<double>) { }
    4040};
    4141
  • branches/safari-609-branch/Source/WebCore/platform/ios/WebCoreMotionManager.mm

    r253357 r259601  
    233233        for (auto& client : motionClients) {
    234234            if (client)
    235                 client->motionChanged(0, 0, 0, accel.x * kGravity, accel.y * kGravity, accel.z * kGravity, 0, 0, 0);
     235                client->motionChanged(0, 0, 0, accel.x * kGravity, accel.y * kGravity, accel.z * kGravity, WTF::nullopt, WTF::nullopt, WTF::nullopt);
    236236        }
    237237    });
  • branches/safari-609-branch/Source/WebKit/ChangeLog

    r259509 r259601  
     12020-04-06  Alan Coon  <alancoon@apple.com>
     2
     3        Cherry-pick r259315. rdar://problem/61352448
     4
     5    Regression(r253357) DeviceMotionEvent acceleration and rotationRate are null
     6    https://bugs.webkit.org/show_bug.cgi?id=209831
     7    <rdar://problem/60720953>
     8   
     9    Reviewed by Darin Adler.
     10   
     11    Source/WebCore:
     12   
     13    The issue was that DeviceMotionClientIOS::motionChanged() would only initialize the
     14    acceleration and rotationRate if [m_motionManager gyroAvailable] returned YES. After
     15    r253357, m_motionManager is nil because we get motion data from the UIProcess so
     16    [m_motionManager gyroAvailable] would always resolve to NO.
     17   
     18    To address the issue, I made the rotationRate parameters to motionChanged() optional
     19    and we rely on them being set to know if gyro data is available. Note that I did not
     20    make the acceleration optional because according to [1], all devices have an
     21    accelerometer.
     22   
     23    [1] https://developer.apple.com/documentation/coremotion/cmmotionmanager/1616094-devicemotionavailable?language=objc
     24   
     25    * platform/ios/DeviceMotionClientIOS.h:
     26    * platform/ios/DeviceMotionClientIOS.mm:
     27    (WebCore::DeviceMotionClientIOS::motionChanged):
     28    * platform/ios/DeviceOrientationUpdateProvider.h:
     29    * platform/ios/MotionManagerClient.h:
     30    (WebCore::MotionManagerClient::motionChanged):
     31    * platform/ios/WebCoreMotionManager.mm:
     32    (-[WebCoreMotionManager sendAccelerometerData:]):
     33   
     34    Source/WebKit:
     35   
     36    * UIProcess/ios/WebDeviceOrientationUpdateProviderProxy.h:
     37    * UIProcess/ios/WebDeviceOrientationUpdateProviderProxy.mm:
     38    (WebKit::WebDeviceOrientationUpdateProviderProxy::motionChanged):
     39    * WebProcess/WebCoreSupport/WebDeviceOrientationUpdateProvider.cpp:
     40    (WebKit::WebDeviceOrientationUpdateProvider::deviceMotionChanged):
     41    * WebProcess/WebCoreSupport/WebDeviceOrientationUpdateProvider.h:
     42    * WebProcess/WebCoreSupport/WebDeviceOrientationUpdateProvider.messages.in:
     43   
     44   
     45    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@259315 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     46
     47    2020-03-31  Chris Dumez  <cdumez@apple.com>
     48
     49            Regression(r253357) DeviceMotionEvent acceleration and rotationRate are null
     50            https://bugs.webkit.org/show_bug.cgi?id=209831
     51            <rdar://problem/60720953>
     52
     53            Reviewed by Darin Adler.
     54
     55            * UIProcess/ios/WebDeviceOrientationUpdateProviderProxy.h:
     56            * UIProcess/ios/WebDeviceOrientationUpdateProviderProxy.mm:
     57            (WebKit::WebDeviceOrientationUpdateProviderProxy::motionChanged):
     58            * WebProcess/WebCoreSupport/WebDeviceOrientationUpdateProvider.cpp:
     59            (WebKit::WebDeviceOrientationUpdateProvider::deviceMotionChanged):
     60            * WebProcess/WebCoreSupport/WebDeviceOrientationUpdateProvider.h:
     61            * WebProcess/WebCoreSupport/WebDeviceOrientationUpdateProvider.messages.in:
     62
    1632020-04-03  Alan Coon  <alancoon@apple.com>
    264
  • branches/safari-609-branch/Source/WebKit/UIProcess/ios/WebDeviceOrientationUpdateProviderProxy.h

    r253357 r259601  
    5050    // WebCore::WebCoreMotionManagerClient
    5151    void orientationChanged(double, double, double, double, double) final;
    52     void motionChanged(double, double, double, double, double, double, double, double, double) final;
     52    void motionChanged(double, double, double, double, double, double, Optional<double>, Optional<double>, Optional<double>) final;
    5353
    5454    // IPC::MessageReceiver
  • branches/safari-609-branch/Source/WebKit/UIProcess/ios/WebDeviceOrientationUpdateProviderProxy.mm

    r253357 r259601  
    7373}
    7474
    75 void WebDeviceOrientationUpdateProviderProxy::motionChanged(double xAcceleration, double yAcceleration, double zAcceleration, double xAccelerationIncludingGravity, double yAccelerationIncludingGravity, double zAccelerationIncludingGravity, double xRotationRate, double yRotationRate, double zRotationRate)
     75void WebDeviceOrientationUpdateProviderProxy::motionChanged(double xAcceleration, double yAcceleration, double zAcceleration, double xAccelerationIncludingGravity, double yAccelerationIncludingGravity, double zAccelerationIncludingGravity, Optional<double> xRotationRate, Optional<double> yRotationRate, Optional<double> zRotationRate)
    7676{
    7777    m_page.send(Messages::WebDeviceOrientationUpdateProvider::DeviceMotionChanged(xAcceleration, yAcceleration, zAcceleration, xAccelerationIncludingGravity, yAccelerationIncludingGravity, zAccelerationIncludingGravity, xRotationRate, yRotationRate, zRotationRate));
  • branches/safari-609-branch/Source/WebKit/WebProcess/WebCoreSupport/WebDeviceOrientationUpdateProvider.cpp

    r253357 r259601  
    9494}
    9595
    96 void WebDeviceOrientationUpdateProvider::deviceMotionChanged(double xAcceleration, double yAcceleration, double zAcceleration, double xAccelerationIncludingGravity, double yAccelerationIncludingGravity, double zAccelerationIncludingGravity, double xRotationRate, double yRotationRate, double zRotationRate)
     96void WebDeviceOrientationUpdateProvider::deviceMotionChanged(double xAcceleration, double yAcceleration, double zAcceleration, double xAccelerationIncludingGravity, double yAccelerationIncludingGravity, double zAccelerationIncludingGravity, Optional<double> xRotationRate, Optional<double> yRotationRate, Optional<double> zRotationRate)
    9797{
    9898    Vector<WeakPtr<WebCore::MotionManagerClient>> clients;
  • branches/safari-609-branch/Source/WebKit/WebProcess/WebCoreSupport/WebDeviceOrientationUpdateProvider.h

    r253357 r259601  
    5252    void stopUpdatingDeviceMotion(WebCore::MotionManagerClient&) final;
    5353    void deviceOrientationChanged(double, double, double, double, double) final;
    54     void deviceMotionChanged(double, double, double, double, double, double, double, double, double) final;
     54    void deviceMotionChanged(double, double, double, double, double, double, Optional<double>, Optional<double>, Optional<double>) final;
    5555
    5656    // IPC::MessageReceiver.
  • branches/safari-609-branch/Source/WebKit/WebProcess/WebCoreSupport/WebDeviceOrientationUpdateProvider.messages.in

    r253357 r259601  
    2424messages -> WebDeviceOrientationUpdateProvider {
    2525    DeviceOrientationChanged(double alpha, double beta, double gamma, double compassHeading, double compassAccuracy)
    26     DeviceMotionChanged(double xAcceleration, double yAcceleration, double zAcceleration, double xAccelerationIncludingGravity, double yAccelerationIncludingGravity, double zAccelerationIncludingGravity, double xRotationRate, double yRotationRate, double zRotationRate)
     26    DeviceMotionChanged(double xAcceleration, double yAcceleration, double zAcceleration, double xAccelerationIncludingGravity, double yAccelerationIncludingGravity, double zAccelerationIncludingGravity, Optional<double> xRotationRate, Optional<double> yRotationRate, Optional<double> zRotationRate)
    2727}
    2828#endif
Note: See TracChangeset for help on using the changeset viewer.