Comments (6)
Hi @GuyKahlon
I from the documentation that I've found online, it looks like CLLocationManager isn't thread safe class, and should be only manipulated from some thread that has runloop :) I don't think it's a usual pattern for users to create their own run loop, although, it's possible ofc.
I can't see any benefit of running CLLocationManager on your runloop instead of main thread, but I could be wrong about this.
I haven't found anything in official documentation that explicitly says the class is thread safe, which means it's not. I could be wrong about this, so if I've missed something, please let me know.
First search results from Google also say it's a really good idea to work with CLLocationManager from main thread
http://www.touch-code-magazine.com/cllocationmanager-and-thread-safety/
http://stackoverflow.com/questions/4000537/receiving-cllocation-updates-on-a-background-thread
Were are you accessing shared instance of location manager, or did you create your own runloop and location manager?
from rxswift.
We've changed wording on error message, so it should be more helpful now.
if !NSThread.currentThread().isMainThread {
rxFatalError("Executing on scheduler that is not main. Please use `MainScheduler.sharedInstance`.")
}
I still think it's a good idea to leave this check :)
from rxswift.
FWIW: in watchOS 2 your extension won't necessarily get instantiated on the main thread (as it is instantiated via XPC), so ensuring objects get created on the main thread becomes problematic. The workaround I've used for now is to defer creation of the object that holds the location manager until applicationDidFinishLaunching()
.
from rxswift.
Hi, guys I wonder will subscribeOn
operator help?
from rxswift.
@sergdort Unfortunately that doesn't help mitigate the issue.
from rxswift.
Hi @AquaGeek ,
yeah, I would suggest using it from main thread only because it's far easier to reason about what is happening. I doubt there would be any performance issues.
I've tried analyzing what would be necessary to make this thread safe, but it wasn't as trivial as it initially seemed since any possible mutations or reading should involve additional synchronization. That would add significant amount of additional synchronizations and make the code harder to read and reason about.
Then we would probably need to add multiple delegate proxy types (or a boolean parameter), one that allows being used from main thread, and other one that doesn't because we would need to safeguard accessing UI elements, so it just gets more and more complex.
I think people are having hard time understanding what is happening even now :)
We've decided for simpler, safer and hoping reasonable solution for now, unless we find some really compelling reasons to add that additional complexity.
¯_(ツ)_/¯
from rxswift.
Related Issues (20)
- Name Conflict from Xcode 15 HOT 24
- Setting `maxConcurrentOperationCount` has no effect on `OperationQueueScheduler`. HOT 3
- RxTest didn't work with Swift concurrency HOT 2
- xcodebuild archive fails for RxCocoa using SPM HOT 4
- Can't compile RxSwift for visionOS HOT 2
- RXCocoa on contextMenuConfigurationForRowAt method HOT 2
- Cannot call value of non-function type '[Observable<Event>.Type]' HOT 2
- crash HOT 1
- Observable from async function HOT 1
- AsyncSequence.asObservable() effect is not as expected
- Missing imports warn 'this is an error in Swift 6'
- docs.rxswift.org (RxSwift Reference) - all links to Documentation/[FILENAME].md are broken HOT 1
- Crash app Xcode 15 HOT 3
- Crash: value tried to resume its continuation more than once HOT 2
- Any support/plan of Privacy Manifest? HOT 119
- Deprecated code warnings in playground Filtering_and_Conditional_Operators.xcplaygroundpage HOT 1
- -[RxCocoa.RxTextViewDelegateProxy text]: unrecognized selector sent to instance 0x28132bdb0 HOT 2
- asSingle -> Sequence contains more than one element. HOT 5
- Update
- Cocoapods trunk push verification fails on pods dependent on RxSwift using Xcode 15+ HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rxswift.