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

Input Array becomes zeros on iOS devices #585

Closed
sukhsung opened this issue Mar 24, 2020 · 22 comments
Closed

Input Array becomes zeros on iOS devices #585

sukhsung opened this issue Mar 24, 2020 · 22 comments
Assignees

Comments

@sukhsung
Copy link

What is wrong?

When I pass an array to kernel, all of entries becomes 0 on iOS devices (Chrome and Safari)

Where does it happen?

Confirmed on at least three devices (my iPad, iPhone and friend's iPhone)

How do we replicate the issue?

Here is minimum working example : https://jsfiddle.net/yzpaefuo/5/

How important is this (1-5)?

5 if I'm not messing something up

Expected behavior (i.e. solution)

I should get same results on both all devices.

Other Comments

I've tested this on android devices and it works fine, and it works on my Mac and PC as well.
It also seems to work properly with older version of gpu.js. Specifically one that worked was 1.10.1

@robertleeplummerjr robertleeplummerjr self-assigned this Mar 24, 2020
@robertleeplummerjr
Copy link
Member

Looking at this now.

@robertleeplummerjr
Copy link
Member

Does using tactic: 'precision' resolve the issue?

@sukhsung
Copy link
Author

No, I think it breaks during evaluation without error. Nothing is being returned.

@sukhsung
Copy link
Author

Actually, I lied. It returns something, but it's little off
0,1,2.01562476158141,2.999999523162842,3.999999761581421
Can this be avoided? My inputs in my actual code are smaller numbers, so having better precision is preferred. I guess I can try premultiply my input to large number and divide in kernel

@robertleeplummerjr
Copy link
Member

I'm still investigating.

@harshkhandeparkar
Copy link

Can I be of any help?

@robertleeplummerjr
Copy link
Member

It seems to be a bug with packing/unpacking floats on ios. Related code is that of "dragons":

// Here be dragons!

@harshkhandeparkar
Copy link

Which floats? User end floats or backend?

@harshkhandeparkar
Copy link

Can a strongly typed function fix this error?

@robertleeplummerjr
Copy link
Member

Which floats? User end floats or backend?

Its complicated, but it has to do with how a 32 bit float array is:

  1. uploaded (Float32Array to UInt8Array)
  2. reconstituted/unpacked (8 bit vec4 -> 32 bit float)
  3. packed (32 bit float -> 8 bit float)
  4. and then downloaded (UInt8Array to Float32Array)

iOS and OSX are notoriously difficult to work with. Their driver's are buggy and they leave things half implemented. Boo Apple!

@harshkhandeparkar
Copy link

harshkhandeparkar commented Mar 24, 2020 via email

@robertleeplummerjr
Copy link
Member

I don't get a bug, per-say, I get a low precision: [0, 1, 2.014709234237671, 2.999084234237671, 3.999084234237671], but that actually does help narrow things down a little.

@harshkhandeparkar
Copy link

glitch rather than a bug.

@harshkhandeparkar
Copy link

Can a strongly typed function fix this error?

?

@harshkhandeparkar
Copy link

Can we not work with integers instead of floats?

@robertleeplummerjr
Copy link
Member

Can a strongly typed function fix this error?

They are already strong types, no.

Can we not work with integers instead of floats?

Uint8Array, it is working with both.

@harshkhandeparkar
Copy link

Why is the output float and not int?

@robertleeplummerjr
Copy link
Member

Why is the output float and not int?

Lets discuss implementation details on gitter, and here focus on the findings we come up with when they are found.

@harshkhandeparkar
Copy link

harshkhandeparkar commented Mar 24, 2020 via email

@robertleeplummerjr
Copy link
Member

It seems that you must use tactic: 'precision' with both Android and iOS, we'll go ahead and make it part of the internals.

@robertleeplummerjr
Copy link
Member

It returns something, but it's little off
0,1,2.01562476158141,2.999999523162842,3.999999761581421

Still investigating that as well.

@robertleeplummerjr
Copy link
Member

Released https://github.com/gpujs/gpu.js/releases/tag/2.9.2 which addresses the inaccurate lookup. My suspicion for values like 0,1,2.01562476158141,2.999999523162842,3.999999761581421 is that there is little we can do about it in the confines of webgl.

ammyk9 pushed a commit to ammyk9/gpu.js that referenced this issue Aug 8, 2024
fix: gpujs#585 add features.isSpeedTacticSupported and tests
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

No branches or pull requests

3 participants