How many mayLaunchUrl we can run at a time?

224 views
Skip to first unread message

Chi, Chang

unread,
Feb 25, 2016, 1:16:31 AM2/25/16
to prer...@chromium.org
Hello, 

This is Chi. I am a developer in PayPal, we are trying to utilize ChromeCustomTabs into our project. I ran into several issue when I used mayLaunchUrl. I checked the code you have on the github. I simply set up an button to test the mayLaunchURL (prerender feature), when I looked up the traffic using chrome dev tool. I did the the traffic and tab got trigger and the url got loaded ( it is simply a GET call with params). However, when I click it multiple times, (after 8-10times, with different params everytime), it STOP working. I stop seeing the requests sent out. (Not seen on chrome dev tool, nor the Proxy I set up). 

I wonder if there is a limit times ( restriction) for mayLaunchURL feature, in other words, how many pages we can pre-render in this case? Is there a way to manually cancel the pre-render page and free the resource?  

is there a restriction in terms of times to bindCustomTabsService? The way I did to call mayLaunchURL is to have an activity and kill the activity once I finish the tab. Can I bind the service each time even I “kill (finish)” the activtiy every time?
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
customTabActivityHelper = new CustomTabActivityHelper();
customTabActivityHelper.setConnectionCallback(this);
}
@Override
protected void onStart() {
super.onStart();
customTabActivityHelper.bindCustomTabsService(this);
}
@Override
public void onCustomTabsConnected() {

Boolean mayLaunchUrlAccepted = customTabActivityHelper.mayLaunchUrl(Uri.parse(“the URL?f=“+params), null, null);
// the mayLaunchUrlAccepted always return true in my case. Even when there is no request sent.
}
——

Chang-Ching Chi 

Android Developer | RiskPD RDA

[
  {
"Phone": "408-609-2376"
"Skype": "changchingchi_PP",
"Email": "ch...@paypal.com",
"Url"  "paypal.com"
  }

]

Matt Menke

unread,
Feb 25, 2016, 3:26:38 AM2/25/16
to Chi, Chang, prer...@chromium.org
about:net-internals#prerender will tell you Chrome's view of the prerenders it sees, and why it cancelled any prerenders that reached its prerendering infrastructure.  Any prerenders that don't show up there would most likely have been blocked code between mayLaunchUrl and Chrome's prerendering infrastructure, which I'm unfamiliar with.

Chi, Chang

unread,
Feb 25, 2016, 12:42:13 PM2/25/16
to Matt Menke, prer...@chromium.org
Hi Matt, 

I wasn’t able to open the link you attached. Can you please show me the URL again?  Also, whom I should talk to to understand the infrastructure? Is there an API/method we can call to reset the blocked code? The most important thing for outside people, without understanding the code itself, its hard to control the behavior of the feature.
——

Chang-Ching Chi 

Android Developer | RiskPD RDA

[
  {
"Phone": "408-609-2376"
"Skype": "changchingchi_PP",
"Email": "ch...@paypal.com",
"Url"  "paypal.com"
  }

]
62CB38CD-DE2C-445E-9876-F1B406C47518[4].png

Matt Menke

unread,
Feb 25, 2016, 12:45:05 PM2/25/16
to Chi, Chang, prer...@chromium.org
It's an internal chrome page (about:net-internals#prerender), so you'll have to manually enter the URL, rather than clicking a link.  I don't know who owns the Android interface, unfortunately.

Matt Menke

unread,
Feb 25, 2016, 12:47:15 PM2/25/16
to Chi, Chang, prer...@chromium.org

Chi, Chang

unread,
Feb 25, 2016, 1:02:02 PM2/25/16
to li...@chromium.org, pa...@chromium.org, yus...@chromium.org, prer...@chromium.org
Moved Matt to Bcc. 
Hello guys, 

Is there any restriction regards to pre-render features? How can we reset the blocked code?
62CB38CD-DE2C-445E-9876-F1B406C47518[4].png
62CB38CD-DE2C-445E-9876-F1B406C47518[8].png

Yusuf Ozuysal

unread,
Feb 25, 2016, 1:38:26 PM2/25/16
to Chi, Chang, li...@chromium.org, pa...@chromium.org, yus...@chromium.org, sbi...@google.com, andr...@google.com, prer...@chromium.org

TL;DR MayLaunchUrl calls are not restricted, but throttled. So you can have as many calls as you want as long as you follow up with a corresponding custom tab launch.

Thanks a lot for reaching out about this!

MayLaunchUrl should only be used after a strong signal from the user that they will go to a certain url and we closely monitor what happened after the mayLaunchUrl call. If an app keeps calling mayLaunchUrl without following up with a corresponding tab launch multiple times, it gets banned from using the API for a while. If this happened on your device, you can reset this by clearing Chrome's data.

Due to technical limitations we can't prerender more than one page currently, so multiple calls to mayLaunchUrl will keep canceling the active one and recreating a new renderer. If instead of a strong single with a single url, you have a low confidence signal for a list of urls, you can call mayLaunchUrl with mayLaunchUrl(null, null, bundleList) and give a list of bundles with each bundle containing a single uri with key CustomTabsService#KEY_URL. This version is not throttled that heavily and does also provide DNS prefetching and early preconnect, giving you a boost in load times for all the urls. Even with this, I would avoid using it with 10s of urls since there is a limit on the number of sockets that can be open at a time.

Hope this helps. Please let us know if you have any other questions about the integration. We would be more than happy to help.

Chi, Chang

unread,
Feb 25, 2016, 2:18:43 PM2/25/16
to Yusuf Ozuysal, li...@chromium.org, pa...@chromium.org, yus...@chromium.org, sbi...@google.com, andr...@google.com, prer...@chromium.org
Hey Yusuf, 

Please see my following question below.
——

Chang-Ching Chi 

Android Developer | RiskPD RDA

[
  {
"Phone": "408-609-2376"
"Skype": "changchingchi_PP",
"Email": "ch...@paypal.com",
"Url"  "paypal.com"
  }

]

From: Yusuf Ozuysal <yus...@google.com>
Date: Thursday, February 25, 2016 at 10:38 AM
To: Chang Chi <ch...@paypal.com>, "li...@chromium.org" <li...@chromium.org>, "pa...@chromium.org" <pa...@chromium.org>, "yus...@chromium.org" <yus...@chromium.org>, "sbi...@google.com" <sbi...@google.com>, "andr...@google.com" <andr...@google.com>
Cc: "prer...@chromium.org" <prer...@chromium.org>
Subject: Re: How many mayLaunchUrl we can run at a time?


TL;DR MayLaunchUrl calls are not restricted, but throttled. So you can have as many calls as you want as long as you follow up with a corresponding custom tab launch.

There might be a possibility that we want to pre-fetch the content of a certain page right before the user go to next step in our native app, they change the setting or config, we would like to see if that is possible to have it pre-render different pages based on our needs without even open a real tab by calling. Once they open the custom tab then we call a certain api to reset previous unused pre-fetch data in order to save the resource. 
customTabsIntent.launchUrl(activity, uri);
CustomTabsIntent customTabsIntent =
new CustomTabsIntent.Builder(customTabActivityHelper.getSession())
.build();
CustomTabActivityHelper.openCustomTab(
this, customTabsIntent, uri, new WebviewFallback());

Thanks a lot for reaching out about this!

MayLaunchUrl should only be used after a strong signal from the user that they will go to a certain url and we closely monitor what happened after the mayLaunchUrl call. If an app keeps calling mayLaunchUrl without following up with a corresponding tab launch multiple times, it gets banned from using the API for a while. If this happened on your device, you can reset this by clearing Chrome's data.

Can you please give me more details about the way you say “cleaning Chrome’s data”? Do you mean to say Chrome cache? Is there any API I could use to clean it? Though I think this is not a practical way as it might clean some cookie existed on browser and impact the user experience later on. OR you are referring to a way to clean specific data generated by CustomTabs? (without impacting other chrome data)

Due to technical limitations we can't prerender more than one page currently, so multiple calls to mayLaunchUrl will keep canceling the active one and recreating a new renderer.

I agree with the approach. I think having only one active render and overwriting the old renderers is a good way to go. But if this is really the design, why my mayLaunchUrl still got blocked? 

If instead of a strong single with a single url, you have a low confidence signal for a list of urls, you can call mayLaunchUrl with mayLaunchUrl(null, null, bundleList) and give a list of bundles with each bundle containing a single uri with key CustomTabsService#KEY_URL. This version is not throttled that heavily and does also provide DNS prefetching and early preconnect, giving you a boost in load times for all the urls. Even with this, I would avoid using it with 10s of urls since there is a limit on the number of sockets that can be open at a time.

Seems to me, this bundle is looking for a fix set of URL. However, We generate the URL dynamically, I don’t think this approach can provide much helps.
When you say sockets, what do you mean specifically in custom tabs? Is there any method you provide can reset the sockets opened by old prerenders? 

Yusuf Ozuysal

unread,
Feb 29, 2016, 1:01:29 PM2/29/16
to Chi, Chang, li...@chromium.org, pa...@chromium.org, yus...@chromium.org, sbi...@google.com, andr...@google.com, prer...@chromium.org
On Thu, Feb 25, 2016 at 11:18 AM Chi, Chang <ch...@paypal.com> wrote:
Hey Yusuf, 

Please see my following question below.
——

Chang-Ching Chi 

Android Developer | RiskPD RDA

[
  {
"Phone": "408-609-2376"
"Skype": "changchingchi_PP",
"Email": "ch...@paypal.com",
"Url"  "paypal.com"
  }

]
62CB38CD-DE2C-445E-9876-F1B406C47518[12].png

Cc: "prer...@chromium.org" <prer...@chromium.org>
Subject: Re: How many mayLaunchUrl we can run at a time?


TL;DR MayLaunchUrl calls are not restricted, but throttled. So you can have as many calls as you want as long as you follow up with a corresponding custom tab launch.

There might be a possibility that we want to pre-fetch the content of a certain page right before the user go to next step in our native app, they change the setting or config, we would like to see if that is possible to have it pre-render different pages based on our needs without even open a real tab by calling. Once they open the custom tab then we call a certain api to reset previous unused pre-fetch data in order to save the resource. 

If it is a list of urls, then I would strongly recommend using the low confidence version detailed below.

 
customTabsIntent.launchUrl(activity, uri);
CustomTabsIntent customTabsIntent =
new CustomTabsIntent.Builder(customTabActivityHelper.getSession())
.build();
CustomTabActivityHelper.openCustomTab(
this, customTabsIntent, uri, new WebviewFallback());

Thanks a lot for reaching out about this!

MayLaunchUrl should only be used after a strong signal from the user that they will go to a certain url and we closely monitor what happened after the mayLaunchUrl call. If an app keeps calling mayLaunchUrl without following up with a corresponding tab launch multiple times, it gets banned from using the API for a while. If this happened on your device, you can reset this by clearing Chrome's data.

Can you please give me more details about the way you say “cleaning Chrome’s data”? Do you mean to say Chrome cache? Is there any API I could use to clean it? Though I think this is not a practical way as it might clean some cookie existed on browser and impact the user experience later on. OR you are referring to a way to clean specific data generated by CustomTabs? (without impacting other chrome data)


I am talking about app data. Settings-> Apps->Chrome->Manage space->Clear data
 
Due to technical limitations we can't prerender more than one page currently, so multiple calls to mayLaunchUrl will keep canceling the active one and recreating a new renderer.

I agree with the approach. I think having only one active render and overwriting the old renderers is a good way to go. But if this is really the design, why my mayLaunchUrl still got blocked? 

The throttling is for privacy purposes. If we let apps prerender any number of urls without launching any custom tabs, then anybody can use the cookie store in Chrome without the user realizing it in the background. The throttling is there to discourage apps from misusing the API. It is meant to be used as a pretty strong indication of the user opening that specific page soon. Like I mentioned if the client is less than 50% sure, the low confidence version should be used.

 

If instead of a strong single with a single url, you have a low confidence signal for a list of urls, you can call mayLaunchUrl with mayLaunchUrl(null, null, bundleList) and give a list of bundles with each bundle containing a single uri with key CustomTabsService#KEY_URL. This version is not throttled that heavily and does also provide DNS prefetching and early preconnect, giving you a boost in load times for all the urls. Even with this, I would avoid using it with 10s of urls since there is a limit on the number of sockets that can be open at a time.

Seems to me, this bundle is looking for a fix set of URL. However, We generate the URL dynamically, I don’t think this approach can provide much helps.
When you say sockets, what do you mean specifically in custom tabs? Is there any method you provide can reset the sockets opened by old prerenders? 

You can insert the urls dynamically into the bundle. No need to have them hardcoded. In the code just create a new bundle for each url and then do putExtra(KEY_URL, Uri.parse(uriString)) for each of them. Then add them all to a bundle list.

I mean network sockets that we can preconnect to on the device. If your list is too long, your previous preconnects will probably start getting overridden.
Reply all
Reply to author
Forward
0 new messages