RESOLVED FIXED 184520
[iOS] Add a mechanism for holding Wi-Fi assertions
https://bugs.webkit.org/show_bug.cgi?id=184520
Summary [iOS] Add a mechanism for holding Wi-Fi assertions
Andy Estes
Reported 2018-04-11 17:25:59 PDT
[iOS] Add a mechanism for holding Wi-Fi assertions
Attachments
Patch (15.49 KB, patch)
2018-04-11 17:34 PDT, Andy Estes
no flags
Patch (15.84 KB, patch)
2018-04-11 23:19 PDT, Andy Estes
no flags
Patch (15.88 KB, patch)
2018-04-11 23:22 PDT, Andy Estes
no flags
Patch (21.48 KB, patch)
2018-04-12 00:18 PDT, Andy Estes
aestes: commit-queue+
Andy Estes
Comment 1 2018-04-11 17:34:44 PDT
Sam Weinig
Comment 2 2018-04-11 17:59:46 PDT
Can this be tested?
Wenson Hsieh
Comment 3 2018-04-11 18:01:30 PDT
(In reply to Sam Weinig from comment #2) > Can this be tested? Not with any existing mechanism in WebKit, unfortunately. This is blocked on <rdar://problem/37710976>.
Sam Weinig
Comment 4 2018-04-11 18:28:00 PDT
Comment on attachment 337756 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=337756&action=review > Source/WebKit/NetworkProcess/cocoa/WiFiAssertionHolder.cpp:61 > +#include <MobileWiFi/WiFiManagerClient.h> > + > +namespace WebKit { > + > +static WiFiManagerClientRef ensureWiFiManagerClient() > +{ > + static WiFiManagerClientRef wiFiManagerClient = WiFiManagerClientCreate(kCFAllocatorDefault, kWiFiClientTypeNormal); > + return wiFiManagerClient; > +} > + > +static uint64_t wiFiAssertionCount; > + > +WiFiAssertionHolder::WiFiAssertionHolder() > +{ > + if (wiFiAssertionCount++) > + return; > + > + RELEASE_LOG(WiFiAssertions, "Acquiring Wi-Fi assertion."); > + WiFiManagerClientSetType(ensureWiFiManagerClient(), kWiFiClientTypeBackground); > +} > + > +WiFiAssertionHolder::~WiFiAssertionHolder() > +{ > + ASSERT(wiFiAssertionCount); > + if (--wiFiAssertionCount) > + return; > + > + RELEASE_LOG(WiFiAssertions, "Releasing Wi-Fi assertion."); > + WiFiManagerClientSetType(ensureWiFiManagerClient(), kWiFiClientTypeNormal); > +} This should probably be in a HAVE(MOBILE_WIFI) #ifdef. Also, it's a bit confusing that taking the assertion puts things in "background' type, and releasing it makes it normal.
Andy Estes
Comment 5 2018-04-11 18:28:54 PDT
(In reply to Sam Weinig from comment #4) > Comment on attachment 337756 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=337756&action=review > > > Source/WebKit/NetworkProcess/cocoa/WiFiAssertionHolder.cpp:61 > > +#include <MobileWiFi/WiFiManagerClient.h> > > + > > +namespace WebKit { > > + > > +static WiFiManagerClientRef ensureWiFiManagerClient() > > +{ > > + static WiFiManagerClientRef wiFiManagerClient = WiFiManagerClientCreate(kCFAllocatorDefault, kWiFiClientTypeNormal); > > + return wiFiManagerClient; > > +} > > + > > +static uint64_t wiFiAssertionCount; > > + > > +WiFiAssertionHolder::WiFiAssertionHolder() > > +{ > > + if (wiFiAssertionCount++) > > + return; > > + > > + RELEASE_LOG(WiFiAssertions, "Acquiring Wi-Fi assertion."); > > + WiFiManagerClientSetType(ensureWiFiManagerClient(), kWiFiClientTypeBackground); > > +} > > + > > +WiFiAssertionHolder::~WiFiAssertionHolder() > > +{ > > + ASSERT(wiFiAssertionCount); > > + if (--wiFiAssertionCount) > > + return; > > + > > + RELEASE_LOG(WiFiAssertions, "Releasing Wi-Fi assertion."); > > + WiFiManagerClientSetType(ensureWiFiManagerClient(), kWiFiClientTypeNormal); > > +} > > This should probably be in a HAVE(MOBILE_WIFI) #ifdef. Ok. > > Also, it's a bit confusing that taking the assertion puts things in > "background' type, and releasing it makes it normal. Agreed. I had to double-check that those are the right types to use. Strangely enough they are.
Andy Estes
Comment 6 2018-04-11 23:19:42 PDT
Andy Estes
Comment 7 2018-04-11 23:20:10 PDT
Andy Estes
Comment 8 2018-04-11 23:22:10 PDT
Andy Estes
Comment 9 2018-04-12 00:18:54 PDT
Andy Estes
Comment 10 2018-04-12 00:55:20 PDT
Chris Dumez
Comment 11 2018-04-12 21:02:16 PDT
Comment on attachment 337778 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=337778&action=review > Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:48 > +#import <WebKitAdditions/NetworkDataTaskCocoaAdditions.mm> Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:48:9: fatal error: 'WebKitAdditions/NetworkDataTaskCocoaAdditions.mm' file not found #import <WebKitAdditions/NetworkDataTaskCocoaAdditions.mm>
Wenson Hsieh
Comment 12 2018-04-12 21:10:05 PDT
Comment on attachment 337778 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=337778&action=review >> Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:48 >> +#import <WebKitAdditions/NetworkDataTaskCocoaAdditions.mm> > > Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:48:9: fatal error: 'WebKitAdditions/NetworkDataTaskCocoaAdditions.mm' file not found > #import <WebKitAdditions/NetworkDataTaskCocoaAdditions.mm> Internal bots seems happy. Did you pull trunk on both repositories?
Chris Dumez
Comment 13 2018-04-12 21:11:12 PDT
(In reply to Wenson Hsieh from comment #12) > Comment on attachment 337778 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=337778&action=review > > >> Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:48 > >> +#import <WebKitAdditions/NetworkDataTaskCocoaAdditions.mm> > > > > Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:48:9: fatal error: 'WebKitAdditions/NetworkDataTaskCocoaAdditions.mm' file not found > > #import <WebKitAdditions/NetworkDataTaskCocoaAdditions.mm> > > Internal bots seems happy. Did you pull trunk on both repositories? Yes I did.
Chris Dumez
Comment 14 2018-04-12 21:12:51 PDT
(In reply to Chris Dumez from comment #13) > (In reply to Wenson Hsieh from comment #12) > > Comment on attachment 337778 [details] > > Patch > > > > View in context: > > https://bugs.webkit.org/attachment.cgi?id=337778&action=review > > > > >> Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:48 > > >> +#import <WebKitAdditions/NetworkDataTaskCocoaAdditions.mm> > > > > > > Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:48:9: fatal error: 'WebKitAdditions/NetworkDataTaskCocoaAdditions.mm' file not found > > > #import <WebKitAdditions/NetworkDataTaskCocoaAdditions.mm> > > > > Internal bots seems happy. Did you pull trunk on both repositories? > > Yes I did. Never mind, I was on a branch...
Note You need to log in before you can comment on or make changes to this bug.