Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bind window object to requestIdleCallback assignment #1414

Merged
merged 1 commit into from
Jan 7, 2022

Conversation

xt0rted
Copy link
Member

@xt0rted xt0rted commented Dec 10, 2021

Checklist:

  • If this PR is a new feature, please provide at least one example link
  • Make sure all of the significant new logic is covered by tests

The issue reported in #942 (comment) is a result of how Firefox is treating the window.requestIdleCallback assignment. In Chrome this works fine, but in Firefox any call to it results in the error:

TypeError: 'requestIdleCallback' called on an object that does not implement interface Window.

I had the same results in v94 and v96.

Another option is to remove the conditional check and shim the function at the top of the file with:

window.requestIdleCallback =
  window.requestIdleCallback ||
  function (cb) {
    const start = Date.now();
    return setTimeout(() => {
      cb({
        didTimeout: false,
        timeRemaining: () => Math.max(0, 50 - (Date.now() - start)),
      });
    }, 1);
  };

Could you test these in Safari? I don't have my MacBook setup right now so I can't confirm if it still work with that.

@xt0rted
Copy link
Member Author

xt0rted commented Dec 10, 2021

@stefanbuck the tests started failing, I think due to GitHub's html changing.

@stefanbuck
Copy link
Member

@stefanbuck the tests started failing, I think due to GitHub's html changing.

Looks like. I thought we run ./packages/blob-reader/scripts/update-fixtures.sh to ensure we have the latest fixture version but this is not true. After running the script a bunch of blob reader tests started failing. Most of them related to the diff view. I'll look into this

@stefanbuck
Copy link
Member

It took me a while to figure out which part changed but here we go #1427

@nikoladev
Copy link

I can confirm that this change fixed OctoLinker for me in Firefox on macOS. After hacking the change into the .xpi manually OctoLinker started working again.

@stefanbuck
Copy link
Member

Thanks for help with this @nikoladev. I'm going to publish a new version later today.

@stefanbuck stefanbuck merged commit 5f15a6b into main Jan 7, 2022
@stefanbuck stefanbuck deleted the xt0rted-patch-1 branch January 7, 2022 20:23
@stefanbuck
Copy link
Member

Fixed in v6.10.1 which is already available

@jdreesen
Copy link

jdreesen commented Jan 11, 2022

It's working again in my Firefox (on Ubuntu), thank you so much! ❤️

/edit: Just tried on Windows, and it works there, too :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants