Coder Social home page Coder Social logo

Comments (14)

abustany avatar abustany commented on July 23, 2024 2

@abustany, thanks for all the context it is super useful!

  • A few questions that i wanted to check on is if you have been having the same issues with android phones or not at all?

The Pixel 3a I tested on supported float textures, but I suppose this will vary across devices.

  • And then i am curious if you are using Vite for your actual project (i am just going off the Stackblitz)

Yes, we are using Vite. It works just fine with VTK, but will give you headaches with Cornerstone for various reasons: circular dependencies that Rollup can't bundle correctly, webpack-specific web worker loading, and broken webpack automatic public path detection. There are workarounds for all of those, happy to help if needed.

  • Finally i just wanted to check if this is for working with volume viewports or stack, or both that you are experiencing these issues (I am working with volume.)

I only use stack images so far, so I can't speak for volumes sorry 😬

from vtk-js.

abustany avatar abustany commented on July 23, 2024 1

hmm the original bug reports was done on iOS 17, which does not report this extension as far as I remember. As you can see in the hacky patch I sent above, there's a check for OES_texture_float_linear. If I'm not mistaken, the issue is rather that vtk.js does not do the proper checks in that specific part of the code, and sends a Float32 texture to the GPU - but it's been couple of weeks since I dealt with this issue so I might remember it wrong.

from vtk-js.

abustany avatar abustany commented on July 23, 2024

Safari on iOS doesn't report the OES_texture_float_linear extension, which Firefox on my desktop reports... What this extension enables seems pretty close to what's done in the OpenGL implementation of Texture's create2DFromRaw. That correlates pretty well with the fact that if I change Float32Array to Uint8Array in the stackblitz posted above, the code works on iOS. There's a fallback for create3DFilterableFromDataArray, but not in create2DFilterableFromDataArray, is there a good reason for this?

from vtk-js.

abustany avatar abustany commented on July 23, 2024

ha, actually the code produces a warning "failed to load OES_text_float_linear", but because I don't have access to the web inspector on the iPhone I couldn't see it 😅

from vtk-js.

abustany avatar abustany commented on July 23, 2024

A question I'm asking myself about the fallback mentioned above: is it ever desirable to truncate the items of a Float32Array to Uint8? If this happens "under the hood", magically, how can the client know and about it and adapt the window values accordingly?

from vtk-js.

abustany avatar abustany commented on July 23, 2024

I'm using the following patch for now, which seems to fix things for the images I care about. I'm not sure if it's good enough as a general solutions though... The patch is against the built version of vtk.js, so it's compatible with yarn patch or pnpm patch:

diff --git a/Rendering/OpenGL/Texture.js b/Rendering/OpenGL/Texture.js
index a48e383723bf3e32afaf03f5e7c6d866b3e4cbbd..b1e091d9f27d2b8a77de63a14160775702cb3c67 100644
--- a/Rendering/OpenGL/Texture.js
+++ b/Rendering/OpenGL/Texture.js
@@ -932,8 +932,8 @@ function vtkOpenGLTexture(publicAPI, model) {
   }
   function processDataArray(dataArray, preferSizeOverAccuracy) {
     const numComps = dataArray.getNumberOfComponents();
-    const dataType = dataArray.getDataType();
-    const data = dataArray.getData();
+    let dataType = dataArray.getDataType();
+    let data = dataArray.getData();
 
     // Compute min max from array
     // Using the vtkDataArray.getRange() enables caching
@@ -955,6 +955,12 @@ function vtkOpenGLTexture(publicAPI, model) {
     if (!model.useHalfFloat) {
       publicAPI.getOpenGLDataType(dataType, true);
     }
+
+    if (dataType === VtkDataTypes.FLOAT && !!model.oglNorm16Ext && !model.context.getExtension('OES_texture_float_linear') && !minArray.some(x => x < -32767) && !maxArray.some(x => x > 32767)) {
+      data = new Int16Array(data);
+      dataType = VtkDataTypes.SHORT;
+    }
+
     return {
       numComps,
       dataType,

The code should probably be moved to updateArrayDataType too.

from vtk-js.

gosvig123 avatar gosvig123 commented on July 23, 2024

@abustany, thanks for all the context it is super useful!

  • A few questions that i wanted to check on is if you have been having the same issues with android phones or not at all?

  • And then i am curious if you are using Vite for your actual project (i am just going off the Stackblitz)

  • Finally i just wanted to check if this is for working with volume viewports or stack, or both that you are experiencing these issues (I am working with volume.)

Thanks for looking into it and hope you might be able to share some additional info - either way have a great day!

from vtk-js.

finetjul avatar finetjul commented on July 23, 2024

@abustany , Thanks for reporting the issue and your investigation. You might want to create PR.

@sankhesh WDYT ?

from vtk-js.

sankhesh avatar sankhesh commented on July 23, 2024

Safari on iOS doesn't report the OES_texture_float_linear extension

Floating point textures have limited support for Safari on iOS. See https://developer.mozilla.org/en-US/docs/Web/API/OES_texture_float_linear

I'm using the following patch for now,

In your patch you're choosing the type based on value range. Instead, I would cast the data to short if the extension is not available and then calculate appropriate shift and scale values for the cast from short back to float in the shaders.

from vtk-js.

abustany avatar abustany commented on July 23, 2024

@sankhesh thanks for the feedback! Yes, that would be better, but then I need to scale the window/levels based on those shift/scale values in the shader too right? The model you describe is superior, but sounded a bit more complex to implement → I didn't go down that route because I wanted a quick fix yesterday 😬 I might have more time after this month to try to implement a proper fix, but if the current fix is "good enough" for my usecase I can't guarantee I'll have time to implement that proper fix (1-person engineering team here 😅).

from vtk-js.

sedghi avatar sedghi commented on July 23, 2024

Based on my investigation the issue is Float Linear interpolation (OES_texture_float_linear) is not supported on iOS devices and was incorrectly reported as supported up until recently in iOS 17

https://bugs.webkit.org/show_bug.cgi?id=264404#c2

from vtk-js.

sedghi avatar sedghi commented on July 23, 2024

I created this PR which would be good enough for a lot of use cases (except the PT Scaled data)

cornerstonejs/cornerstone3D#1212

from vtk-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.