material icon indicating copy to clipboard operation
material copied to clipboard

md-scroll-shrink height calculation creates an endless $timeout loop

Open AdamMcCormick opened this issue 11 years ago • 7 comments

We use protractor and protractor waits to start testing until all $timeouts have completed to start running. This doesn't seem to have caused us any issue until we tried to introduce the md-scroll-shrink directive onto our toolbar. This seems to create an endless look of $timeout calls in what looks like an attempt to "debounce" the resize request. the loop runs through the updateToolbarHeight method if that's helpful for debugging. Is that the intended behavior? Why not set an interval if it really needs to spin like that?

AdamMcCormick avatar Oct 28 '15 21:10 AdamMcCormick

I took a quick look at this, but I'm not 100% sure what exactly is causing your issue.

I suspect it might be something with our use of $$raf(updateToolbarHeight), but I'll need to dig into it a bit more.

If you have a chance to dig in first, some additional debugging (or perhaps a very basic GitHub repo that shows the Protractor issue) would be very helpful.

topherfangio avatar Oct 29 '15 17:10 topherfangio

The site we saw this on is extremely simple, really just a form with a toolbar at the top. Shouldn't be a hard case to recreate, but I don't have the cycles at the moment.

AdamMcCormick avatar Oct 29 '15 17:10 AdamMcCormick

I looked into this a little bit myself. From protractor's output when I have the error, I think the timeout in question is invoked by the material util debounce function here: https://github.com/angular/material/blob/cf7f21aa6c633d9f0bd22013e9a79f99b82b16af/src/core/util/util.js#L411

And I think this is the line setting up the debounce: https://github.com/angular/material/blob/c668ba4027db865283eb2665df8ce3d0fde24e2f/src/components/toolbar/toolbar.js#L92

Hope this helps!

mrmeku avatar Dec 22 '15 23:12 mrmeku

+1, this is still a pretty jarring problem and I have yet to find a workaround for it.

Judging by the protractor error output I get and a little grepping, I have the same hunch as @mrmeku about the timeout being invoked by the debounce function.

For reference, here is the output Protractor gives when using the md-scroll-shrink directive on a page:

Failed: Timed out waiting for Protractor to synchronize with the page after 11 seconds.
The following tasks were pending:
- $timeout: function () {

          timer = undefined;
          func.apply(context, args);

        }

ThomasvLingen avatar Jan 05 '16 10:01 ThomasvLingen

This issue is really-really distressing, because it can prevent from developing and using Protractor integration tests on a whole project. We heavily rely on material, but cannot maintain our integration tests since we introduced material in the project.

I gave it a try and was able to get Protractor tests run on my local machine by using $interval instead of $timeout in the function mentioned by @mrmeku.

   debounce: function(func, wait, scope, invokeApply) {
      var timer;

      return function debounced() {
        var context = scope,
          args = Array.prototype.slice.call(arguments),
          noRepeat = 1;

        $interval.cancel(timer);
        timer = $interval(function() {

          timer = undefined;
          func.apply(context, args);

        }, wait || 10, noRepeat, invokeApply);
      };
    }

But material unit tests fail after this modification. All failures are in the unit test of the md-datapicker.

david-hajba avatar Mar 30 '16 08:03 david-hajba

This issue is closed as part of our deprecation effort. For details, see our post Spring Cleaning 2016.

ThomasBurleson avatar Apr 28 '16 20:04 ThomasBurleson

This message was created automatically by mail delivery software.

A message that you sent could not be delivered to one or more of its recipients. This is a temporary error. The following address(es) deferred:

[email protected] Domain biomassiv.es has exceeded the max emails per hour (514/500 (102%)) allowed. Message will be reattempted later

------- This is a copy of the message, including all the headers. ------ Received: from o1.sgmail.github.com ([192.254.114.176]:26149) by ps5.websitehostserver.net with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.86_1) (envelope-from [email protected]) id 1avsc7-000L31-7q for [email protected]; Thu, 28 Apr 2016 15:32:43 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=github.com; h=from:reply-to:to:cc:in-reply-to:references:subject:mime-version:content-type:content-transfer-encoding:list-id:list-archive:list-post:list-unsubscribe; s=s20150108; bh=+ChwnjIyuty+B9EGO1cPtZeBlVA=; b=vyzBredhOVZ8FyyB xZbh2aMlfr7Pef4MoTSDPZ0CiAZrJ2KH/80zkgXMTA8Li2ZSDtezsHccobakyY9K xKRS2KhcHHHd2BlY+LQesmQQbZQhTeckwFxmFvHKAGxY1/ufzEwvoKX1Yig5pmi8 k/0kUeSnN46HvuDqccLB3Wnpmlk= Received: by filter0830p1mdw1.sendgrid.net with SMTP id filter0830p1mdw1.22550.5722734A26 2016-04-28 20:32:10.398007905 +0000 UTC Received: from github-smtp2a-ext-cp1-prd.iad.github.net (github-smtp2a-ext-cp1-prd.iad.github.net [192.30.253.16]) by ismtpd0002p1iad1.sendgrid.net (SG) with ESMTP id fzRreHLSRiWCIvIi1-nkWQ for [email protected]; Thu, 28 Apr 2016 20:32:10.435 +0000 (UTC) Date: Thu, 28 Apr 2016 13:32:10 -0700 From: Thomas Burleson [email protected] Reply-To: angular/material [email protected] To: angular/material [email protected] Cc: Message-ID: angular/material/issues/5417/[email protected] In-Reply-To: angular/material/issues/[email protected] References: angular/material/issues/[email protected] Subject: Re: [angular/material] md-scroll-shrink height calculation creates an endless $timeout loop (#5417) Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="--==_mimepart_5722734a2e213_2aba3fdf7ca132b8381db"; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: list X-GitHub-Sender: ThomasBurleson X-GitHub-Recipient: biomassives List-ID: angular/material <material.angular.github.com> List-Archive: https://github.com/angular/material List-Post: mailto:[email protected] List-Unsubscribe: mailto:unsub+0042d4e298b7040a9edf6ec95ebc5fccafef4a64d985c6ae92cf00000001133a354a92a169ce06ca4e53@reply.github.com, https://github.com/notifications/unsubscribe/AELU4s9lOOvWXCEa3p9botDkxKXmD4SLks5p8RlKgaJpZM4GXuo7 X-Auto-Response-Suppress: All X-GitHub-Recipient-Address: [email protected] X-SG-EID: ZlaDthyue/4HG+EgTb7JoZYs48JNb2iQtCcPV6oIs9WUuMwNgK3d6XayfvlAnJ+ajPSiA0/8THGpxC IflMjVH6Lrvl2M4rOSh+9UtucDmBWVq7At5kheS1Qk2alx3voq/5ntJht+9GYM/A1F6Gu3kipKo9J7 BSNG/ztg0n+rmj5H8SdS7qFj4Yy5qFRwXTX73vcsOySFpjIA5T39SPWh+tw0fZJUvV+Gc7b5AKPvTc A=

----==_mimepart_5722734a2e213_2aba3fdf7ca132b8381db Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit

This issue is closed as part of our deprecation effort. For details, see our post Spring Cleaning 2016.


You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/angular/material/issues/5417#issuecomment-215552020 ----==_mimepart_5722734a2e213_2aba3fdf7ca132b8381db Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit

This issue is closed as part of our deprecation effort.
For details, see our post Spring Cleaning 2016.

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub

----==_mimepart_5722734a2e213_2aba3fdf7ca132b8381db--

biomassives avatar Apr 28 '16 20:04 biomassives