Use cronet request url,appears URLRequestContextGetter leaking due to no owning thread

159 views
Skip to first unread message

王明明

unread,
Feb 7, 2018, 11:54:58 AM2/7/18
to Chromium-dev



When I use Cronet request url muti times, it happens to Crash. The code is as below




- (void)startRequest

{


    [Cronet initialize];


    [Cronet setRequestFilterBlock:^(NSURLRequest* request) {


        return YES;


    }];


    StartCronet(443);


   


    _configuration = [NSURLSessionConfiguration ephemeralSessionConfiguration];


    _configuration.requestCachePolicy = NSURLRequestReloadIgnoringLocalCacheData;


   


    [Cronet registerHttpProtocolHandler];


    [Cronet installIntoSessionConfiguration:_configuration];


   


    _session = [NSURLSession sessionWithConfiguration:_configuration];


   


    NSURL *url = [NSURL URLWithString:@"https://vip.qzone.qq.com/proxy/domain/qzonestyle.gtimg.cn/qzone/space_item/boss_pic/2472_2017_11/1512034326193_704231.jpg"];


    NSURLSessionDataTask* task = [_session dataTaskWithURL:url completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {


        if (data) {


            dispatch_async(dispatch_get_main_queue(), ^{


                UIImage *image =  [UIImage imageWithData:data];


                [_imageViewQuic setImage:image];


            });


        }


    }];


   


   


    StartDataTaskAndWaitForCompletion(task);


}




void StartCronet(int port) {


    //    [Cronet setUserAgent:@"CronetTest/1.0.0.0" partial:NO];


    [Cronet setQuicEnabled:true];


    [Cronet setHttp2Enabled:false];


    [Cronet setBrotliEnabled:false];


    [Cronet setAcceptLanguages:@"zh-CN,zh;q=0.9"];


    //    [Cronet setExperimentalOptions:[NSString stringWithFormat:@"{\"ssl_key_log_file\":\"%@\"}", [Cronet getNetLogPathForFile:@"SSLKEYLOGFILE"]]];


    BOOL result = [Cronet addQuicHint:@"vip.qzone.qq.com" port:443 altPort:443];


   


    [Cronet enableTestCertVerifierForTesting];


    [Cronet setHttpCacheType:CRNHttpCacheTypeDisabled];


    [Cronet start];


    NSString* rules = [NSString stringWithFormat:@"MAP vip.qzone.qq.com vip.qzone.qq.com:%d",


                       port];


    [Cronet setHostResolverRulesForTesting:rules];


}




void StartDataTaskAndWaitForCompletion(NSURLSessionDataTask* task) {


    [task resume];


}


And every time I call startRequest method, it will print the warning log. 

WARNING:url_request_context_getter.cc(43)] URLRequestContextGetter leaking due to no owning thread.


Has anyone faced the same question?  How to solve it, please?


Helen Li

unread,
Feb 7, 2018, 2:19:12 PM2/7/18
to wmm...@gmail.com, Chromium-dev, net-dev, kapis...@chromium.org
+net-dev, kapishnikov


--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev+unsubscribe@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/67211484-d88c-4403-8f95-dd3577fabe03%40chromium.org.

Matt Menke

unread,
Feb 7, 2018, 2:19:53 PM2/7/18
to Helen Li, wmm...@gmail.com, Chromium-dev, net-dev, kapis...@chromium.org
For the record, "Cronet" here means "iOS Cronet".  We don't use URLRequestContextGetter on Android, and really shouldn't on iOS, either.

--
You received this message because you are subscribed to the Google Groups "net-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to net-dev+unsubscribe@chromium.org.
To post to this group, send email to net...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/net-dev/CAEkFr040ZAR%2BH_zBv%2BERSkW614RyZaHemjifNZc1Tcv6Ny-hgw%40mail.gmail.com.

Andrei Kapishnikov

unread,
Feb 7, 2018, 3:41:36 PM2/7/18
to Matt Menke, Helen Li, wmm...@gmail.com, Chromium-dev, net-dev, kapis...@chromium.org
You don't need to call [Cronet initialize] directly every time a request is sent. In fact, the method is not a part of the public interface and should never be called by a Cronet client. Also, [Cronet start] should only be called once per app execution. If you follow these steps, you should not see this error message every time startRequest is called. The message may appear only once when the app terminates.

王明明

unread,
Feb 7, 2018, 9:11:39 PM2/7/18
to Chromium-dev, mme...@chromium.org, xunj...@chromium.org, wmm...@gmail.com, net...@chromium.org, kapis...@chromium.org
Thanks a lot!!! It helps. I delete "[Cronet initialize] " , and call  [Cronet start] only once. ^-^

在 2018年2月8日星期四 UTC+8上午4:41:36,Andrei Kapishnikov写道:
+net-dev, kapishnikov


--
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.

--
You received this message because you are subscribed to the Google Groups "net-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to net-dev+u...@chromium.org.
Reply all
Reply to author
Forward
0 new messages