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

Unexpected module.runSetters wrapping #277

Open
jpambrun opened this issue May 31, 2021 · 6 comments · May be fixed by #326
Open

Unexpected module.runSetters wrapping #277

jpambrun opened this issue May 31, 2021 · 6 comments · May be fixed by #326

Comments

@jpambrun
Copy link

I am using reify 0.20.12 from Meteor and am importing vec3 from gl-matrix.

My issue is that this function:

/**
 * Normalize a vec3
 *
 * @param {vec3} out the receiving vector
 * @param {ReadonlyVec3} a vector to normalize
 * @returns {vec3} out
 */
export function normalize(out, a) {
  let x = a[0];
  let y = a[1];
  let z = a[2];
  let len = x * x + y * y + z * z;
  if (len > 0) {
    len = 1 / Math.sqrt(len);  
  }
  out[0] = a[0] * len;
  out[1] = a[1] * len;
  out[2] = a[2] * len;
  return out;
}

once run through reify becomes:

function normalize(out, a) {
  var x = a[0];
  var y = a[1];
  var z = a[2];
  var len = x * x + y * y + z * z;
  if (len > 0) {
    module.runSetters(len = 1 / Math.sqrt(len));    // <----- unexpected module.runSetters
    out[0] = a[0] * len;
    out[1] = a[1] * len;
    out[2] = a[2] * len;
  }
  return out;
}

I suspect the issue triggered because another len is later exported :

/**
 * Alias for {@link vec3.length}
 * @function
 */
export const len = length;

being a heavy 3D application, normalize is called 100s or 1000s of times per frame and this needless callback is really killing performance. Is this expected? Any way to avoid it?

@simplecommerce
Copy link

We seem to be experiencing a similar issue on our end when using Material-UI v5 with MeteorJS.
I am adding a link to our discussions here.

https://forums.meteor.com/t/material-ui-v5-dialogs-and-menus-initial-open-lags-freezes/56842/2

A fellow user seems to have narrowed the issue to this package.

I am also linking my issue that I posted on MUI's github for reference.

mui/material-ui#29131

@quintstoffers
Copy link

I'm not quite sure if the issue is identical, as this particular issue seems to be a case where the exported variable is incorrectly wrapped (since it's actually a different len variable), correct?

Regardless, the slowdowns when using Material UI 5 (read: emotion) in combination with Meteor (read: reify) seem to be caused by exports in the stylis package. I brought it up there (thysultan/stylis#278), but to be fair it's not really their problem.

@ksinas
Copy link

ksinas commented Nov 11, 2021

Meteor + MUI5 is unusable due to this issue. It takes 600ms for me to render a simple form dialog, while other built systems doesn't have this issue.

@filipenevola
Copy link

Hi, reify is not part of Meteor officially but we use it to compile our code so we (Meteor) are going to take a look at this issue soon.

Keep following here or in the Forums for updates.

@zodern zodern linked a pull request Nov 19, 2021 that will close this issue
@filipenevola
Copy link

Hi all, could you give a try at Meteor 2.5.2-beta.0?

More details here.

@filipenevola
Copy link

Meteor 2.5.2 includes this fix. meteor#1

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.

5 participants