Comments (10)
Curious .. as you say, "none of this should ever be touching the main thread." Can you quantify the "Doesn't happen often, but occasionally" frequency? I'll check the AsyncUdpSocket code -- I've not read the documentation for a few years!
from ios-ntp.
If you add the "CocoaLumberjack" code to your project, set "#if 1" around line 32 in GCDAsyncUdpSocket.h, and add "#import "DDTTYLogger.h" in your app delegate and #import "DDTTYLogger.h" in your "didFinishLaunchingWithOptions" method, you'll detailed tracing inside the GCDAsyncUdpSocket code.
Meanwhile, I'm reading code and documentation ..
from ios-ntp.
Thanks for the quick reply, Gavin! Sorry for the vagueness in my original post.
Out of the 3 weeks we've been using the library, this has only happened a couple of times today within a minute or two of each other while I was on the metro/subway, so I'm guessing it's network related and something I'll try replicating using the "network link conditioner" debugging tool on device.
I guess the larger concern was the fact that the GCSAsyncUdpSocket
class was using a dispatch_sync
which locks the main thread until it's finished. A more normal pattern would be:
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
// Do some work here in the background thread
// Once we have something to report to the UI, dispatch it back to the main thread
dispatch_async(dispatch_get_main_queue(), ^{
// Update UI or call completion/error block
});
});
from ios-ntp.
D’you think we should bump this up to the CocoaAsynch project, Rob ?
On Apr 27, 2015, at 4:00 PM, rob phillips [email protected] wrote:
I guess the larger concern was the fact that the GCSAsyncUdpSocket class was using a dispatch_sync which locks the main thread until it's finished. A more normal pattern would be:
from ios-ntp.
For sure, just wanted to make you aware of it since it also impacts all of the users of this library unfortunately
from ios-ntp.
Just to update: this seems to be happening a couple of times each day during testing and we are even receiving failed to scene-update in time
crashes from the main thread hanging on this. Since CocoaAsyncSocket appears to be abandoned, we are going to remove this for now instead of trying to fix.
from ios-ntp.
Hm .. If it is worth maintaining a time capability like ios-ntp, I could look at using AFNetworking instead of CocoaAsyncSocket as a UDP layer. I use its TCP services in other work, but haven't looked at how much the UDP methods stay off the main-thread.
from ios-ntp.
AFNetworking won't handle connectionless networking, and I'm not going to adopt the CocoaAsyncSocket code, so I'm not sure what to do about this. Thinking ..
from ios-ntp.
You may want to look into: https://github.com/square/SocketRocket
from ios-ntp.
Will do .. meanwhile:
In the "initWithServerName" method of "NetAssociation" the socket to be used is given the "dispatch_get_main_queue()" as its "delegateQueue:". This seems likely to interfere with the main thread's work, so I changed that line to:
socket = [[GCDAsyncUdpSocket alloc] initWithDelegate:self
delegateQueue:dispatch_queue_create("com.ramsaycons.ios-ntp", DISPATCH_QUEUE_SERIAL)];
When I run the ios-ntp-app with that change[1] I see that the times reported by the various servers are less dispersed (much less!). I'm not familiar enough with GCD, or CocoaAsyncSocket, to know if I'm doing a Good Thing™ but you've got a test case I can reproduce and I'm wondering if you could try this (if you think it makes sense)?
Doing this has modified the 'instant time' derivation from immediate to several seconds so, meanwhile, I'll explore the reason for that. I suspect the slowdown of the hit rate on the time servers is involved ..
[1] The "delegateQueue:" could be different for each "NetAssociation" too, I guess.
from ios-ntp.
Related Issues (20)
- iOS-ntp returning same value as device HOT 4
- Question for one-time check HOT 4
- Watching possible issue in CocoaAsyncSocket code
- Cocoa Pods released version HOT 1
- Hardcoded NTP Pool names HOT 13
- import error HOT 1
- EXC_BAD_ACCESS HOT 6
- What is missing from RFC 5905 HOT 2
- Grabbing ntpClientRecvTime Twice HOT 1
- Ability to Change the Time Servers Without Reboot
- Account for Packet Loss in One-Off Mode HOT 1
- Any update for cocoapod, version is still 1.1.1 HOT 2
- v1.1.7 updates coming soon .. HOT 1
- when not network to network, error: " dnssd_clientstub deliver_request ERROR:"
- Does not compile because of lacking GCDAsyncUpdSocket HOT 3
- 该网络时间从哪来?
- 有啥用呢? HOT 1
- How to get the accurate network time after modifying the system time HOT 13
- demo clock is wrong HOT 5
- Whether the poll interval can be automatically increase?
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 ios-ntp.