Skip to content

fix: blank green screen when opening game link directly - #75

Open
IkeyBenz wants to merge 2 commits into
mainfrom
fix/direct-game-link-blank-screen
Open

IkeyBenz wants to merge 2 commits into
mainfrom
fix/direct-game-link-blank-screen

Conversation

@IkeyBenz

Copy link
Copy Markdown
Collaborator

Problem

Opening a game link directly (e.g., modi.app/games/abc123) showed a blank green background. Users had to refresh to see the lobby content.

Root Cause

Race condition between auth initialization and UI rendering. When navigating directly to a game link:

  1. Firebase anonymous auth starts but takes time to complete
  2. AuthProvider called setUserId AFTER awaiting getIdToken(true) token refresh
  3. Meanwhile, UsernameProvider's onAuthStateChanged fires, causing splash screen to hide
  4. GameScreen renders with currentUserId=null, showing empty ScreenContainer
  5. Token refresh completes, setUserId finally called - but splash already hidden, user sees green screen

Solution

Three targeted fixes:

1. AuthProvider (providers/Auth.tsx)

Set userId immediately when auth succeeds, move token refresh to background:

// Before: userId set after token refresh
await result.user.getIdToken(true);
setUserId(result.user.uid);

// After: userId set immediately, token refreshed in background  
setUserId(result.user.uid);
await result.user.getIdToken(true);

2. useGame hook (ui/screens/Game/hooks/useGame.ts)

Guard against undefined gameId during initial route parsing:

if (!gameId) {
  return; // Don't subscribe to invalid path
}

3. GameScreen (ui/screens/Game/index.tsx)

Use isAuthLoading state for proper loading behavior:

const { userId: currentUserId, isLoading: isAuthLoading } = useAuth();
if (isAuthLoading || !gameId || !game || !currentUserId) {
  return <ScreenContainer />;
}

Testing

The fix ensures the UI has the auth state before the splash screen hides, eliminating the race condition that caused the blank green screen.

@vercel

vercel Bot commented Jan 29, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
modi-app Ready Ready Preview, Comment Feb 8, 2026 3:48pm

Root cause: On direct navigation to game URL, auth hasn't completed yet
but the screen renders showing a blank green background.

Fix:
1. AuthProvider uses onAuthStateChanged to set userId immediately
2. SplashScreenProvider waits for AuthProvider.isLoading
3. Game screen shows loading spinner while auth/game data loads
   (instead of blank green screen)
@IkeyBenz
IkeyBenz force-pushed the fix/direct-game-link-blank-screen branch from e4574ff to e3a06b2 Compare January 30, 2026 00:15
@IkeyBenz
IkeyBenz temporarily deployed to modi-api-pr-75 January 30, 2026 00:16 Inactive

This branch was successfully deployed

1 active and 1 inactive (outdated) deployments
Preview — dec3dd73 Deployed Feb 8, 2026 by vercel[bot]
modi-api-pr-75 — e3a06b24 Deployed Jan 30, 2026 by IkeyBenz
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 this pull request may close these issues.

1 participant