Skip to content

isMobile() returns true on Linux desktop with touchscreen #284

@manuel-kroeter

Description

@manuel-kroeter

On Linux, navigator.maxTouchPoints > 0 can be true on desktop machines with a touchscreen. isMobile() interprets this as mobile, halving the SplatPager page pool (256 → 128 pages). The existing Windows guard correctly handles this case for Windows touch devices — the same guard should cover Linux, since Linux is always a desktop OS regardless of touch capability.

export function isMobile(): boolean {
  const platform = navigator.platform.toLowerCase();
  if (platform.startsWith("win") || platform.startsWith("linux")) {
    return false;
  }
  if (navigator.maxTouchPoints > 0) {
    // Touch-enabled device, assume it's mobile
    return true;
  }
  return /Mobi|Android|iPhone|iPad|iPod|Opera Mini|IEMobile/.test(
    navigator.userAgent,
  );
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions