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

ReferenceError in PlatformBrowser.setTimeoutCustom #6922

Closed
khcyt opened this issue Oct 10, 2022 · 7 comments
Closed

ReferenceError in PlatformBrowser.setTimeoutCustom #6922

khcyt opened this issue Oct 10, 2022 · 7 comments
Labels
type:bug Something isn't working

Comments

@khcyt
Copy link

khcyt commented Oct 10, 2022

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): all
  • Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device:
  • TensorFlow.js installed from (npm or script link): npm
  • TensorFlow.js version (use command below): 3.21
  • Browser version:
  • Tensorflow.js Converter Version:

Describe the current behavior

I run tensorflow in browser a separate worker thread. This is why there is an exception in PlaformBrowser.setTimeoutCustom()

platform_browser.js:53 Uncaught (in promise) ReferenceError: window is not defined
at PlatformBrowser.setTimeoutCustom (platform_browser.js:53:9)
at tryFn (util_base.js:287:13)
at util_base.js:289:9
at new Promise ()
at repeatedTry (util_base.js:274:12)
at GPGPUContext.addItemToPoll (gpgpu_context.js:398:9)
at gpgpu_context.js:375:18
at new Promise ()
at GPGPUContext.pollFence (gpgpu_context.js:374:16)
at GPGPUContext.createAndWaitForFence (gpgpu_context.js:165:21)

Describe the expected behavior

The expected behavior would be that window is not assumed to exist.
Eiter !globalThis.window or 'undefined'== typeof window

@khcyt khcyt added the type:bug Something isn't working label Oct 10, 2022
gyagp added a commit to gyagp/tfjs that referenced this issue Oct 10, 2022
In worker thread, window doesn't exist so !window will raise a
referenceError. Check "typeof window" to fix this.

BUG tensorflow#6922
@gyagp
Copy link
Collaborator

gyagp commented Oct 10, 2022

@khcyt thanks for reporting the issue! Submitted a PR as above.

mattsoulanille added a commit that referenced this issue Oct 10, 2022
In worker thread, window doesn't exist so !window will raise a
referenceError. Check "typeof window" to fix this.

BUG #6922

Co-authored-by: Matthew Soulanille <msoulanille@google.com>
@rthadur
Copy link
Contributor

rthadur commented Oct 10, 2022

Related PR #6923 has been merged , closing this issue.

@rthadur rthadur closed this as completed Oct 10, 2022
@google-ml-butler
Copy link

Are you satisfied with the resolution of your issue?
Yes
No

@bentzibentz
Copy link

I'm using the actual v4.1.0 version, installed via github and i get still this error, cause the fix is missing:

setTimeoutCustom(functionRef, delay) {
        if (!window || !env().getBool('USE_SETTIMEOUTCUSTOM')) {
            setTimeout(functionRef, delay);
            return;
        }

Which release i have to install to get the correct version?

@gyagp
Copy link
Collaborator

gyagp commented Jan 4, 2023

@bentzibentz The fix was included in v4.0.0, and I just checked the github version (tfjs-core/src/platforms/platform_browser.ts). Could you please double check?

@bentzibentz
Copy link

@gyagp maybe the problem is, my installation of tsfj installs @tensorflow/tfjs-core v3.21.0
I manually install the latest version and now it is fixed, thanks for pointing me to the right direction.

@gyagp
Copy link
Collaborator

gyagp commented Jan 4, 2023

yes, tfjs-core v3.21.0 still has this problem and the version after it (v4.0.0) is the first one to fix it. Glad to know you're fine now.

PrafulB added a commit to PrafulB/tfjs that referenced this issue Feb 25, 2024
tfjs v4.0+ solves issue tensorflow#6922 which caused it to not be usable in web workers. tfjs-automl still used v3.9.0 . This fork updates it to 4.9.0+ , same as in its devDependencies.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants