Giter Club home page Giter Club logo

devicesensorsplugin's People

Contributors

rdelrosario avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

devicesensorsplugin's Issues

iOS Accelerometer StartReading silent crash (Potential bug)

Hey,

I've been using this plugin in my Xamarin app and it works fine on Android. I was having problems with iOS where the StartListening call would just crash silently. I couldn't get your project to restore properly in my solution so I just took your code and added it in to test what the problem was.

I am calling the StartReading function on the Accelerometer from a System.Timers.Timer.Elapsed callback, meaning there's no NSOperationQueue.CurrentQueue since this value only reflects the operation queue that launched the opration. This causes a silent crash and doesn't provide any feedback from your plugin.

I would make the change and make a PR, but as mentioned above the project is not restoring in my solution (which contains .netstandard2 libs) and I don't want to submit PR not tested by me.

I fixed the problem by just using NSOperation.MainQueue instead of CurrentQueue and the reading works again, just as a workaround for now.

Suggestions:

  • Use NSOperation.MainQueue in Platforms/iOS/AccelerometerDeviceSensor.cs line 51
  • Additionally: Use the NSError returned (if any) to throw an exception in OnAccelerometerChanged
  • Additionally: Surround _motionManager.StartAccelerometerUpdates(NSOperationQueue.CurrentQueue, OnAccelerometerChanged); in a try catch and throw a custom exception to indicate "Not called from the UIThread" or something in those regards or you can make sure the call is being performed on the UI thread to ensure that NSOperationQueue.CurrentQueue is not null.

If I missed anything and it's my code causing the issue you can just close this.

I hope this helps

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.