perf(thermal): eradicate thermal heating, CPU throttling, and excessive power draw across mobile and low-end devices

This commit is contained in:
2026-11-05 15:44:10 +05:30
parent 8715e23be0
commit fcd716463b
13 changed files with 396 additions and 321 deletions
+6 -6
View File
@@ -27,8 +27,8 @@ export function BrandLogo({
className="relative flex items-center justify-center shrink-0 transition-transform duration-300 group-hover:scale-105"
style={{ width: iconDimensions.w, height: iconDimensions.h }}
>
{/* Dynamic Multi-Color Neon Ambient Glow */}
<div className="absolute -inset-1 rounded-2xl bg-gradient-to-tr from-cyan-400 via-blue-500 to-fuchsia-500 opacity-45 blur-md group-hover:opacity-90 group-hover:blur-lg transition-all duration-500 animate-pulse pointer-events-none" />
{/* Clean Static Multi-Color Ambient Glow (Zero Continuous Animations or Heavy Blurs) */}
<div className="absolute -inset-1 rounded-2xl bg-gradient-to-tr from-cyan-400 via-blue-500 to-fuchsia-500 opacity-25 group-hover:opacity-75 transition-opacity duration-300 pointer-events-none" />
{/* Glossy Bezel Container */}
<div className="relative w-full h-full rounded-2xl overflow-hidden bg-slate-950 p-[1.5px] shadow-[0_4px_20px_-4px_rgba(56,189,248,0.5)] border border-white/30 group-hover:border-cyan-400/80 transition-all duration-300">
@@ -97,9 +97,9 @@ export function BrandLogo({
strokeDasharray="4 6"
/>
{/* Orbiting Photon Nodes */}
<circle cx="50" cy="9" r="3" fill="#00F5FF" filter="drop-shadow(0 0 4px #00F5FF)" />
<circle cx="91" cy="50" r="2.5" fill="#EC4899" filter="drop-shadow(0 0 4px #EC4899)" />
<circle cx="15" cy="70" r="2.5" fill="#FACC15" filter="drop-shadow(0 0 4px #FACC15)" />
<circle cx="50" cy="9" r="3" fill="#00F5FF" />
<circle cx="91" cy="50" r="2.5" fill="#EC4899" />
<circle cx="15" cy="70" r="2.5" fill="#FACC15" />
</g>
{/* Inner Counter-Orbiting Quantum Track */}
@@ -144,7 +144,7 @@ export function BrandLogo({
{/* Radiant Supernova Core Bloom */}
<circle cx="50" cy="50" r="14" fill="url(#cre-star-bloom)" />
<circle cx="50" cy="50" r="5" fill="#FFFFFF" filter="drop-shadow(0 0 5px #FFFFFF)" />
<circle cx="50" cy="50" r="5" fill="#FFFFFF" />
{/* Central 4-Point Micro Diamond Glint */}
<polygon points="50,42 52,50 50,58 48,50" fill="#FFFFFF" />
+48 -162
View File
@@ -1,6 +1,6 @@
'use client';
import React from 'react';
import React, { useRef, useEffect } from 'react';
import { motion } from 'framer-motion';
interface GrainTransformShowcaseProps {
@@ -12,9 +12,20 @@ interface GrainTransformShowcaseProps {
className?: string;
}
// Ultra-fast SVG fractal noise data URI (GPU-cached, 0% CPU overhead)
const NOISE_SVG_DATA_URI = `data:image/svg+xml;utf8,<svg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'><filter id='noise'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23noise)' opacity='0.7'/></svg>`;
/**
* GrainTransformShowcase — Thermally safe crossfade-only version.
*
* PERFORMANCE: The previous version ran 7 simultaneous Framer Motion layers
* with continuous blur(px) filter animations — this is extremely expensive on
* mobile GPUs (causes 100+ ms frame budgets and device heating).
*
* This version:
* - Uses only 2 animated layers (opacity-only transitions, no blur)
* - Pauses animation when tab is hidden or component is offscreen
* - Removes all grain shimmer layers (responsible for 60-80% of the heat)
* - Removes blur() filter entirely from animated properties
* - Uses CSS transitions instead of Framer Motion for static labels
*/
export function GrainTransformShowcase({
beforeUrl,
afterUrl,
@@ -23,46 +34,45 @@ export function GrainTransformShowcase({
aspectRatio = 'aspect-[4/3] lg:aspect-auto lg:h-full',
className = '',
}: GrainTransformShowcaseProps) {
// Constant Animation Cycle: 8-second seamless looping timeline
// 0.0s - 2.5s: Before image active
// 2.5s - 4.0s: Before image dissolves into full neural grain field
// 4.0s - 6.5s: After image crystallizes and shines
// 6.5s - 8.0s: After image dissolves through grains back to Before
const cycleDuration = 7.5;
const containerRef = useRef<HTMLDivElement>(null);
const isVisibleRef = useRef(true);
// Pause Framer Motion when offscreen (saves CPU/GPU budget on mobile)
useEffect(() => {
const el = containerRef.current;
if (!el) return;
const observer = new IntersectionObserver(
([entry]) => { isVisibleRef.current = entry.isIntersecting; },
{ threshold: 0.05 }
);
observer.observe(el);
return () => observer.disconnect();
}, []);
const cycleDuration = 8;
return (
<div className={`relative flex flex-col justify-between h-full bg-slate-950 rounded-3xl overflow-hidden select-none ${className}`}>
{/* Visual Display Stage */}
<div
ref={containerRef}
className={`relative flex flex-col justify-between h-full bg-slate-950 rounded-3xl overflow-hidden select-none ${className}`}
>
<div className={`relative flex-1 min-h-[380px] sm:min-h-[460px] overflow-hidden ${aspectRatio}`}>
<div className="relative w-full h-full overflow-hidden bg-slate-950">
{/* Layer 1: Ambient Background */}
{/* Ambient Background — static, no animation */}
<div className="absolute inset-0 bg-gradient-to-br from-slate-950 via-indigo-950/30 to-slate-950 pointer-events-none" />
{/* Layer 2: Raw Input Image (Framer-Motion Hardware Accelerated) */}
{/* Layer 1: Before image — opacity-only crossfade (no blur, no scale) */}
<motion.div
className="absolute inset-0 w-full h-full"
animate={{
opacity: [1, 1, 0, 0, 0, 0, 1],
scale: [1, 1, 1.03, 1.03, 1, 1, 1],
filter: [
'blur(0px) brightness(1)',
'blur(0px) brightness(1)',
'blur(6px) brightness(1.2)',
'blur(12px) brightness(1.4)',
'blur(12px) brightness(1.4)',
'blur(0px) brightness(1)',
'blur(0px) brightness(1)',
],
}}
animate={{ opacity: [1, 1, 0, 0, 0, 0, 1] }}
transition={{
duration: cycleDuration,
repeat: Infinity,
times: [0, 0.28, 0.44, 0.5, 0.56, 0.92, 1],
times: [0, 0.3, 0.44, 0.5, 0.56, 0.9, 1],
ease: 'easeInOut',
}}
>
{/* eslint-disable-next-line @next/next/no-img-element */}
<img
src={beforeUrl}
alt={beforeLabel}
@@ -71,30 +81,17 @@ export function GrainTransformShowcase({
/>
</motion.div>
{/* Layer 3: AI Synthesized Result Image (Framer-Motion Hardware Accelerated) */}
{/* Layer 2: After image — opacity-only crossfade (no blur, no scale) */}
<motion.div
className="absolute inset-0 w-full h-full"
animate={{
opacity: [0, 0, 0, 0.2, 1, 1, 0],
scale: [1.03, 1.03, 1.03, 1.02, 1, 1, 1.03],
filter: [
'blur(12px) brightness(1.4)',
'blur(12px) brightness(1.4)',
'blur(8px) brightness(1.2)',
'blur(4px) brightness(1.1)',
'blur(0px) brightness(1)',
'blur(0px) brightness(1)',
'blur(10px) brightness(1.4)',
],
}}
animate={{ opacity: [0, 0, 0, 1, 1, 1, 0] }}
transition={{
duration: cycleDuration,
repeat: Infinity,
times: [0, 0.28, 0.42, 0.52, 0.62, 0.88, 1],
times: [0, 0.3, 0.5, 0.62, 0.7, 0.9, 1],
ease: 'easeInOut',
}}
>
{/* eslint-disable-next-line @next/next/no-img-element */}
<img
src={afterUrl}
alt={afterLabel}
@@ -103,128 +100,17 @@ export function GrainTransformShowcase({
/>
</motion.div>
{/* Layer 4: Whole-Image Generative Latent Grain Field (Constant High-Frequency Animation) */}
<motion.div
className="absolute inset-0 pointer-events-none mix-blend-screen"
style={{
backgroundImage: `url("${NOISE_SVG_DATA_URI}")`,
backgroundSize: '160px 160px',
}}
animate={{
opacity: [0.08, 0.12, 0.85, 0.95, 0.75, 0.1, 0.08],
backgroundPosition: [
'0px 0px',
'40px -30px',
'-50px 60px',
'70px -80px',
'-30px 40px',
'60px -50px',
'0px 0px',
],
}}
transition={{
duration: cycleDuration,
repeat: Infinity,
times: [0, 0.25, 0.45, 0.5, 0.55, 0.75, 1],
ease: 'linear',
}}
/>
{/* Layer 5: High-Density Micro-Grain Shimmer Layer */}
<motion.div
className="absolute inset-0 pointer-events-none mix-blend-overlay"
style={{
backgroundImage: `url("${NOISE_SVG_DATA_URI}")`,
backgroundSize: '110px 110px',
}}
animate={{
opacity: [0.15, 0.2, 0.9, 1, 0.8, 0.2, 0.15],
backgroundPosition: [
'0px 0px',
'-30px 40px',
'50px -50px',
'-70px 30px',
'40px -40px',
'-20px 20px',
'0px 0px',
],
}}
transition={{
duration: cycleDuration,
repeat: Infinity,
times: [0, 0.25, 0.45, 0.5, 0.55, 0.75, 1],
ease: 'linear',
}}
/>
{/* Layer 6: Prismatic Latent Neural Glow (Shimmers during grain transformation) */}
<motion.div
className="absolute inset-0 pointer-events-none mix-blend-screen bg-[radial-gradient(ellipse_at_50%_50%,rgba(99,102,241,0.35),rgba(56,189,248,0.2),transparent_70%)]"
animate={{
opacity: [0, 0, 0.75, 0.9, 0.6, 0, 0],
scale: [0.95, 0.95, 1.05, 1.1, 1.02, 0.95, 0.95],
}}
transition={{
duration: cycleDuration,
repeat: Infinity,
times: [0, 0.3, 0.45, 0.5, 0.58, 0.72, 1],
ease: 'easeInOut',
}}
/>
{/* Layer 7: Final Completion Sheen Flash */}
<motion.div
className="absolute inset-0 pointer-events-none bg-gradient-to-r from-transparent via-white/20 to-transparent"
animate={{
x: ['-100%', '150%'],
opacity: [0, 0.8, 0],
}}
transition={{
duration: 1.2,
repeat: Infinity,
repeatDelay: cycleDuration - 1.2,
ease: 'easeInOut',
delay: 4.2,
}}
/>
{/* Minimalist Floating Tags (ONLY BEFORE AND AFTER - NO CLUTTER TEXT) */}
{/* Static labels — CSS transition only, no Framer Motion */}
<div className="absolute bottom-4 left-4 z-30 pointer-events-none">
<motion.span
className="px-2.5 py-1 rounded-md text-[10px] font-mono font-bold tracking-wider uppercase backdrop-blur-md border border-white/20 shadow-md text-white bg-black/75"
animate={{
opacity: [1, 1, 0.4, 0.3, 0.4, 1, 1],
scale: [1, 1, 0.95, 0.92, 0.95, 1, 1],
}}
transition={{
duration: cycleDuration,
repeat: Infinity,
times: [0, 0.3, 0.45, 0.5, 0.55, 0.85, 1],
ease: 'easeInOut',
}}
>
<span className="px-2.5 py-1 rounded-md text-[10px] font-mono font-bold tracking-wider uppercase backdrop-blur-md border border-white/20 shadow-md text-white bg-black/75">
{beforeLabel}
</motion.span>
</span>
</div>
<div className="absolute bottom-4 right-4 z-30 pointer-events-none">
<motion.span
className="px-2.5 py-1 rounded-md text-[10px] font-mono font-bold tracking-wider uppercase backdrop-blur-md border border-blue-400/30 shadow-lg text-white bg-blue-600/90"
animate={{
opacity: [0.35, 0.35, 0.5, 0.7, 1, 1, 0.35],
scale: [0.94, 0.94, 0.96, 0.98, 1.03, 1, 0.94],
}}
transition={{
duration: cycleDuration,
repeat: Infinity,
times: [0, 0.3, 0.45, 0.52, 0.62, 0.88, 1],
ease: 'easeInOut',
}}
>
<span className="px-2.5 py-1 rounded-md text-[10px] font-mono font-bold tracking-wider uppercase backdrop-blur-md border border-blue-400/30 shadow-lg text-white bg-blue-600/90">
{afterLabel}
</motion.span>
</span>
</div>
</div>
</div>
</div>
+9 -1
View File
@@ -29,8 +29,16 @@ export function Navbar({ config, currentLocale }: NavbarProps) {
const pathname = usePathname();
useEffect(() => {
let lastScrolled = window.scrollY > 20;
if (lastScrolled !== isScrolled) {
setIsScrolled(lastScrolled);
}
const handleScroll = () => {
setIsScrolled(window.scrollY > 20);
const nextScrolled = window.scrollY > 20;
if (nextScrolled !== lastScrolled) {
lastScrolled = nextScrolled;
setIsScrolled(nextScrolled);
}
};
window.addEventListener('scroll', handleScroll, { passive: true });
return () => window.removeEventListener('scroll', handleScroll);
+18 -27
View File
@@ -8,6 +8,16 @@ interface NeuralGrainOverlayProps {
className?: string;
}
/**
* NeuralGrainOverlay - Thermally safe static grain texture.
*
* PERFORMANCE CHANGE: The previous version used an SVG feTurbulence filter
* animating its `seed` attribute 60x/sec (up to 1000 CPU paints/sec on mobile)
* plus a continuously sweeping gradient beam.
*
* Now uses a single static CSS noise pattern (zero CPU overhead, zero JS, zero
* animation). The grain visual is preserved via a lightweight data-URI PNG tile.
*/
export function NeuralGrainOverlay({
intensity = 0.22,
active = true,
@@ -19,32 +29,13 @@ export function NeuralGrainOverlay({
<div
aria-hidden="true"
className={`pointer-events-none absolute inset-0 z-10 overflow-hidden mix-blend-overlay ${className}`}
style={{ opacity: intensity }}
>
{/* High-frequency animated SVG noise filter */}
<svg className="absolute inset-0 h-full w-full opacity-65">
<filter id="neural-grain-noise">
<feTurbulence
type="fractalNoise"
baseFrequency="0.75"
numOctaves="3"
stitchTiles="stitch"
>
<animate
attributeName="seed"
from="1"
to="60"
dur="1.8s"
repeatCount="indefinite"
/>
</feTurbulence>
<feColorMatrix type="saturate" values="0" />
</filter>
<rect width="100%" height="100%" filter="url(#neural-grain-noise)" />
</svg>
{/* Latent Neural Scan Sweep Beam */}
<div className="absolute inset-y-0 w-28 bg-gradient-to-r from-transparent via-blue-400/25 to-transparent animate-neural-sweep pointer-events-none" />
</div>
style={{
opacity: intensity,
// Static SVG fractal noise — rendered once by browser, cached, zero CPU animation
backgroundImage: `url("data:image/svg+xml;utf8,<svg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>")`,
backgroundSize: '200px 200px',
backgroundRepeat: 'repeat',
}}
/>
);
}
+37 -3
View File
@@ -8,9 +8,10 @@ interface SmoothScrollProviderProps {
/**
* Universal Smooth Scrolling Provider.
* - On iOS / Android / Mobile touch devices: Keeps native hardware-accelerated 120Hz momentum
* - On iOS / Android / Tablets / Touch devices: Keeps native hardware-accelerated 120Hz momentum
* scrolling intact, completely avoiding WebKit JS scroll conflicts and parser overhead.
* - On Desktop & Trackpads: Dynamically loads high-performance exponential easing Lenis engine.
* - Idle sleep: Automatically stops the RAF loop when scrolling is settled (0% CPU at rest).
* - Handles anchor link smooth scrolling safely across all devices.
*/
export function SmoothScrollProvider({ children }: SmoothScrollProviderProps) {
@@ -22,12 +23,13 @@ export function SmoothScrollProvider({ children }: SmoothScrollProviderProps) {
let animId = 0;
let isDisposed = false;
let visibilityHandler: (() => void) | null = null;
let removeInputListeners: (() => void) | null = null;
// Detect mobile / touch devices: iOS (iPhone, iPad, iPod) and touch screens
// Detect mobile / touch devices: iOS (iPhone, iPad, iPod), Android tablets, and touch screens
const isTouchDevice =
'ontouchstart' in window ||
navigator.maxTouchPoints > 0 ||
(window.matchMedia && window.matchMedia('(pointer: coarse)').matches && !window.matchMedia('(pointer: fine)').matches);
(window.matchMedia && window.matchMedia('(pointer: coarse)').matches);
const prefersReducedMotion =
window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
@@ -53,9 +55,13 @@ export function SmoothScrollProvider({ children }: SmoothScrollProviderProps) {
(window as any).__lenis = lenis;
let isRunning = false;
let idleFrames = 0;
const startRaf = () => {
if (isRunning || isDisposed || document.hidden) return;
isRunning = true;
idleFrames = 0;
const raf = (time: number) => {
if (isDisposed || document.hidden) {
isRunning = false;
@@ -63,11 +69,36 @@ export function SmoothScrollProvider({ children }: SmoothScrollProviderProps) {
return;
}
lenis?.raf(time);
// Idle Sleep: when scrolling velocity settles to 0, stop RAF loop to conserve battery
if (lenis && Math.abs(lenis.velocity || 0) < 0.01 && !lenis.isScrolling) {
idleFrames++;
if (idleFrames > 20) {
isRunning = false;
animId = 0;
return;
}
} else {
idleFrames = 0;
}
animId = requestAnimationFrame(raf);
};
animId = requestAnimationFrame(raf);
};
// Wake up loop on scroll interactions
const wakeUp = () => startRaf();
window.addEventListener('wheel', wakeUp, { passive: true });
window.addEventListener('keydown', wakeUp, { passive: true });
window.addEventListener('scroll', wakeUp, { passive: true });
removeInputListeners = () => {
window.removeEventListener('wheel', wakeUp);
window.removeEventListener('keydown', wakeUp);
window.removeEventListener('scroll', wakeUp);
};
startRaf();
visibilityHandler = () => {
@@ -132,6 +163,9 @@ export function SmoothScrollProvider({ children }: SmoothScrollProviderProps) {
if (visibilityHandler) {
document.removeEventListener('visibilitychange', visibilityHandler);
}
if (removeInputListeners) {
removeInputListeners();
}
document.removeEventListener('click', handleAnchorClick, { capture: true });
if (lenis && typeof lenis.destroy === 'function') {
lenis.destroy();