Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
skip calling getRemixValidPathsGenerationContext if not in remixScene (…
…#6073) **Problem:** When resizing a PromiseCard, it takes 7-8 ms to run useGetStoryboardRoot / getValidElementPaths which seems to spend most of its time on Remix matchRoutes. **Diagnosis:** Turns out, we had this three lines of code running for _every single element visited_ during the recursive `getValidElementPathsFromElement` walk: ``` const isRemixScene = isRemixSceneElement(element, filePath, projectContents) const remixPathGenerationContext = getRemixValidPathsGenerationContext(path) if (remixPathGenerationContext.type === 'active' && isRemixScene) { ``` `getRemixValidPathsGenerationContext` is not trivially cheap to call, and it only returns a sensible result if `path` points at a remix scene. **Fix:** Only call getRemixValidPathsGenerationContext if `isRemixScene` is true. Now `useGetStoryboardRoot` only takes 0.7ms instead of 7ms. <img width="120" alt="image" src="https://github.com/user-attachments/assets/750c33ac-13e1-43fd-90d1-200439ab5708"> **Note:** 0.7ms still feels excessive to run on every single frame, I'll continue the investigation and make a follow up PR **Manual Tests:** I hereby swear that: - [x] I opened a hydrogen project and it loaded - [x] I could navigate to various routes in Preview mode Fixes #6065
- Loading branch information