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

Lost wakeup with ethereum.enable() using many browser tabs #5941

Closed
ghost opened this issue Dec 17, 2018 · 6 comments · Fixed by #6006
Closed

Lost wakeup with ethereum.enable() using many browser tabs #5941

ghost opened this issue Dec 17, 2018 · 6 comments · Fixed by #6006
Assignees

Comments

@ghost
Copy link

ghost commented Dec 17, 2018

When a dapp using ethereum.enable() is opened in two browser tabs, reloading two tabs at the same time locks one of them (the other loads successfully).

Steps to reproduce the behavior:

  1. Prepare the following HTML file:
<html>
<body>
<script type="text/javascript">
console.log('init');
ethereum.enable().then(() => console.log('enabled'));
</script>
</body>
</html>
  1. Open the HTML in two browser tabs
  2. Refresh the tabs quickly (for me it was not even necessary to use Refresh All)
  3. One tab logs 'init' and 'enabled', but the other one logs only 'init'

Both tabs should log 'init' and 'enabled' to the console.

Note that I had granted the permission for MetaMask to inject ethereum account for the location, so no popup appeared during the bug reproduction.
To reproduce, the HTML file location must be http://, file:// does not work.

Software versions:

  • Fedora release 29 (Linux 4.19.6)
  • Chromium 70.0.3538.110
  • MetaMask 5.2.2
@pr0fedt
Copy link

pr0fedt commented Dec 18, 2018

There are more cases of such behavior:

  1. In development reloading of page in a background tab, triggered by recompiling source code also locks that page
  2. When you reopen chrome browser it restores closed tabs. Metamask enabled page remains locked

@Veniamin
Copy link

+1!

@wwwebdiller
Copy link

the same issue is on my side guys

@spigell
Copy link

spigell commented Dec 21, 2018

I have same issue!

@bitpshr bitpshr self-assigned this Dec 26, 2018
@bitpshr
Copy link
Contributor

bitpshr commented Dec 26, 2018

Thanks for filing this @kkostalkowicz. We're investigating this issue now and hope to include a fix as part of the next release.

@ghost ghost added the in progress label Jan 9, 2019
@OFRBG
Copy link

OFRBG commented Jan 9, 2019

There is a workaround using an event listener.

Before you need any web3:

document.addEventListener('visibilitychange', this.enable, false)

Enable call:

enable = () => {
  if(document.hidden) return;

  window.ethereum.enable()
    .then((address) => { /* Your setup with enabled web3 */ })
    .finally(() => {
      document.removeEventListener('visibilitychange', this.enable, false)
    });
}

@ghost ghost removed the in progress label Jan 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants