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

[Desktop] FP blocking: OffscreenCanvas not protected in WorkerGlobalScope #11254

Closed
abrahamjuliot opened this issue Aug 17, 2020 · 2 comments
Closed
Labels
closed/duplicate Issue has already been reported OS/Android Fixes related to Android browser functionality OS/Desktop

Comments

@abrahamjuliot
Copy link

OffscreenCanvas context is not protected in WorkerGlobalScope

Possible contexts parameters include:

  • 2d (tested)
  • webgl
  • webgl2
  • bitmaprenderer

Related issue #9186

Steps to Reproduce

  • turn on fingerprint blocking (standard and strict) and generate OffscreenCanvas data URI from worker scope
  • exit/restart browser and repeat
  • compare results

Tested in Nightly 1.14.44 desktop

Example code:

// worker.js
(async () => {
  let canvas2d
  try {
    const canvas = new OffscreenCanvas(256, 256)
    const context = canvas.getContext('2d')
    const str = 'sP6V85pee$5pRs5yH8&VyGJ3NFSo'
    context.font = '20px Arial'
    context.fillText(str, 100, 100)
    context.fillStyle = 'red'
    context.fillRect(100, 30, 80, 50)
    context.font = '32px Times New Roman'
    context.fillStyle = 'blue'
    context.fillText(str, 20, 70)
    context.font = '20px Arial'
    context.fillStyle = 'green'
    context.fillText(str, 10, 50)
    const getDataURI = async () => {
      const blob = await canvas.convertToBlob()
      const reader = new FileReader()
      reader.readAsDataURL(blob)
      return new Promise(resolve => {
        reader.onloadend = () => resolve(reader.result)
      })
    }
    canvas2d = await getDataURI()
  } catch (error) {}

  postMessage({
    canvas2d
  })
  close()
})()

// script.js
(async () => {
  const getWorkerOffscreenCanvas = () => {
    return new Promise(resolve => {
      try {
        const worker = new Worker('worker.js')
        worker.addEventListener('message', async event => {
          const {
            data: {
              canvas2d
            }
          } = event
          return resolve(canvas2d)
        }, false)
      } catch (error) {
        return resolve(undefined)
      }
    })
  }

  const result = await getWorkerOffscreenCanvas()
  console.log(result)
})()
@abrahamjuliot abrahamjuliot added OS/Android Fixes related to Android browser functionality OS/Desktop labels Aug 17, 2020
@pes10k
Copy link
Contributor

pes10k commented Aug 21, 2020

Hi @abrahamjuliot , thank you for the issue! Both this and #11253 have the same underlying issue, being tracked in #11368.

I am going to close these issues in favor of the general issue / solution, just to keep things tidy. Thank you again for the report!

@abrahamjuliot
Copy link
Author

@pes10k awesome. Thank you too :) ☕

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed/duplicate Issue has already been reported OS/Android Fixes related to Android browser functionality OS/Desktop
Projects
None yet
Development

No branches or pull requests

2 participants