Open DoctorRyner opened 5 months ago
Here is the video of solid looking laggy even for the most basic view https://github.com/solidjs/solid-router/assets/24430919/186fe747-700c-4696-81fd-78e482204545
A reproduction would really help here, even if it does happen with 'any solid app with this router and links', I for example haven't experienced it in my apps. Could it be something to do with transitions causing page navigation to be delayed while waiting for stuff to load?
Yeah hmm.. I'm not seeing it. Even with 6x CPU slowdown on desktop. It is possible there is some sort of performance thing. Maybe even platform specific. Do you see this same lag on: https://docs.solidjs.com/? This is a real site so there are other considerations there but I just want to sort of figure out where to narrow this down a bit because as Brendonovich says there are 1000s of sites out there using the router and this hasn't been reported before.
Look how slow it is on Solid compared to Svelte
Isn't this more related to network being slow and the routes being loaded lazily? Maybe there is also a element in perception involved, since the nav on solid docs does close before the route is finished loading.
I noticed that the payload from the loaded route data in the svelte docs is like < 100B
(depending on the page of course) while the route data loaded in solid docs is more in the ~ 80kB
range.
@DoctorRyner did you have a look at the network tab (for size comparison) and while trying to throttle the network speed?
The page size doesn’t matter, it’s slow even in bare app with no js/css
I use SvelteKit rn and I don’t have this issue in my app. Look at the video I posted above, this is how it works on an iPhone even on bare app. For some reason the route changing is slow on iPhone
Yeah hmm.. I'm not seeing it. Even with 6x CPU slowdown on desktop. It is possible there is some sort of performance thing. Maybe even platform specific. Do you see this same lag on: https://docs.solidjs.com/? This is a real site so there are other considerations there but I just want to sort of figure out where to narrow this down a bit because as Brendonovich says there are 1000s of sites out there using the router and this hasn't been reported before.
Hello @oddcelot @ryansolid , Have you consider to change Network throttling to Slow 3g and try switching between routes. There is no indicator that the page is loading and it looks like the page is frozen.
It isn't fetching from network after loading them first time.
It is slow even on a macbook m1 / asahi, compared to svelte docs. But I think it's related to expressive-code
block being inited. As if you find parts that dont have many, and hide from active viewport, then it's fast, otherwise it's several hundred milliseconds, you can see the title change first and blink before the rest of the articles comes in (not from network), so whilst most people wouldn't consider that slow it's still odd. I think probably a docs issue
@mattbdc nah, I first experienced it in my bare bone project, so it must be related to router
We've been experiencing this in a Tauri + Solid project on iOS, it seems to happen with <a>
links but not <button onClick={() => navigate(...)}>
The problem is that safari iOS adds a 200ms delay to anchor links if you have a mouseover event installed. I tried finding an official source for this, but all I could find was a random reddit comment.
The following hack removes the delay for me.
function useFastAnchorLinks() {
let skipNextMouseOver = false
const onTouchStart = () => {
skipNextMouseOver = true
}
const onCaptureMouseOver = (event: MouseEvent) => {
if (skipNextMouseOver) {
event.preventDefault()
skipNextMouseOver = false
}
}
document.addEventListener("touchstart", onTouchStart)
document.addEventListener("mouseover", onCaptureMouseOver, { capture: true })
onCleanup(() => {
document.removeEventListener("touchstart", onTouchStart)
document.removeEventListener("mouseover", onCaptureMouseOver, { capture: true })
})
}
When I looked into this, I was surprised to see that solid-router hooks into a bunch of global events for this instead of attaching them to the A
component alone.
Possible fixes:
mouseenter
instead of mouseover
hereevt.preventDefault()
inside the mouseover handler...There is another source of a click delays that need separate fixing, though those are not caused by solid-router You need something like the following in your head element.
<meta name="viewport" content="width=device-width, initial-scale=1" />
or alternatively, you need style="touch-action: manipulation;"
on all your anchor links
Interesting, just anecdotal/unbenchmarked it definitely felt like more than 200ms to me, it felt closer to 1s, I'm not sure I would notice 200ms, I wonder what svelte is doing as that didn't suffer..
Interesting, just anecdotal/unbenchmarked it definitely felt like more than 200ms to me, it felt closer to 1s, I'm not sure I would notice 200ms, I wonder what svelte is doing as that didn't suffer..
I think the delay mentioned in my second comment is more than 300ms. Perhaps they are even additive....
I face the same problem with slow page changing when using either <A>
or <a>
.
A minimal reproduction code can be found here: https://github.com/JensForstmann/slow-solidjs-router
I also included a video/screen recording.
Disabling route prefetching seems to fix this on IOS.
I personally disabled the default prefetching on hover behaviour and used an Intersection observer which tracks links appearing on the viewport and preloads the routes manually through the usePreloadRoute
API. This setup requires detecting when new tags are loaded into the DOM to add them to the list of observed items.
Combined with a good CDN caching setup on preloaded queries, and this makes your app feel super fast and snappy on navigation.
Disabling route prefetching seems to fix this on IOS.
Thanks for the tip. I've disabled it for my simple app and it makes it remarkably better to use on iOS.
Describe the bug
Changing pages takes way too much time on iOS and even on desktop if the app is a bit demanding like when it has a background animation. It doesn't matter is it's SSR or standard SPA. I checked with svelte-kit and it is always instant there
Your Example Website or App
any solid app with this router and links
Steps to Reproduce the Bug or Issue
Expected behavior
Screenshots or Videos
No response
Platform
Additional context
No response