EST. 2026 — Notes from real server work SYSADMIN · SECURITY · AI · DIRECTADMIN Issue 01
THE SYSADMIN ALMANAC
Home / Web / 3D View Blank on Some Networks While Nearby Charts Work
Web

3D View Blank on Some Networks While Nearby Charts Work

by Ton-Or ·30 Nov 2026·10 min read
3D View Blank on Some Networks While Nearby Charts Work

When a page breaks only on certain networks, the problem often is not our code but something we borrowed from elsewhere without counting it as part of the system. The clue is which parts of the page still load, and where those parts come from.

1-minute summary

Symptom / problem
The 3D panel of a dashboard is blank on some mobile networks, some LAN machines and in-app chat browsers
Who should read
Developers of Three.js pages that load modules through an importmap from a CDN
Fix in short
Replace the importmap pointing at an external CDN with modules in a same-host vendor folder, add a shim and a flag confirming the loop runs, and prove it by blocking the CDN
Jump to steps

I was building a server room dashboard for a client, with a cartoon-style 3D view animated by live data. After it had been in use for a while, someone reported that the 3D area was blank: they could see only numbers and charts, with no room image. It loaded normally every time I opened it on my own machine, so I spent a long time suspecting WebGL and the reporting user's graphics card, even though the answer had been in their first report: the numbers and charts still loaded.

I have replaced all filenames, machine addresses, and endpoint names in this article with generic ones. The symptoms, cause, and verification method are real.

Symptoms: Only the 3D Area Was Blank, and Only on Some Networks

The project was a single HTML file that used Three.js to draw a server room, then fetched live data to drive its colors and movement. Around the 3D area were temperature readings and historical charts. I deployed this same file in two places.

Location 1

LAN Server

  • Opened at http://192.168.10.40/app/view3d.html
  • Fetched data from api.php on the same machine
  • Polled every 1 second
  • For users on the LAN
Location 2

External Web Host

  • Opened at https://example.com/view3d
  • Fetched data from the site's /api
  • Polled every 5 seconds
  • For users outside the LAN

To avoid maintaining two files, I had the page check its own hostname and choose the settings accordingly.

// ไฟล์เดียว ใช้ได้สองที่: ดูจากชื่อโฮสต์ว่าตอนนี้อยู่ฝั่งไหน
const ON_WEB = location.hostname.indexOf('example.com') !== -1;
const CFG = ON_WEB
  ? { api: '/api',    pollMs: 5000, home: '/' }
  : { api: 'api.php', pollMs: 1000, home: 'index.html' };

async function tick() {
  const r = await fetch(CFG.api, { cache: 'no-store' });
  applyData(await r.json());          // อัปเดตตัวเลข กราฟ และสีใน scene
}
setInterval(tick, CFG.pollMs);

The people reporting a blank 3D area fell into three groups: users on certain mobile networks, users who tapped a link in a chat app and opened the page in its built-in browser, and, unexpectedly, some LAN machines configured without internet access. All three groups saw the same thing: all the numbers, temperatures, and historical charts appeared, but the canvas was blank with no message. My development machine never showed the problem once.

Wrong Guesses: Blaming WebGL, the Graphics Card, and the Scene Code

When 3D content fails to appear on some machines, the first thought is that those machines do not support WebGL or have graphics driver problems. I investigated that first, then wondered whether my scene creation code contained something certain browsers did not like.

Neither explanation accounted for why the symptoms followed the network more closely than the machine or graphics card model, or why the affected LAN machines happened to be the ones without internet access.

The decisive clue came from splitting the page into two groups based on where each piece came from.

Part of the Page Loaded From Result on Affected Machines
HTML and CSS Same host as the page Loaded
Numbers and temperatures API on the same host Loaded
Historical charts API on the same host Loaded
Three.js module External CDN Did not load

Everything from the same host loaded. Only the one piece fetched from outside failed. Once I laid it out this way, WebGL and the graphics card dropped off the suspect list.

A Question to Ask Before Opening the Console

When part of a page breaks, first ask: how do the sources of the working and broken parts differ? Which domains do they load from, which protocols do they use, and what must they pass through before reaching the user's machine? Answering this can eliminate half the hypotheses without even touching the reporting user's machine.

The Culprit: An importmap Pointing to a CDN

My original code followed the examples commonly seen online: an importmap mapped the name three to a file on a CDN.

<!-- ของเดิม: โมดูลทั้งหมดมาจากข้างนอก -->
<script type="importmap">
{ "imports": {
  "three": "https://cdn.jsdelivr.net/npm/[email protected]/build/three.module.js",
  "three/addons/": "https://cdn.jsdelivr.net/npm/[email protected]/examples/jsm/"
}}
</script>
<script type="module">
  import * as THREE from 'three';
  import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
  // ... สร้าง scene ทั้งหมด ...
</script>

A module script differs from a regular script in that the browser must load every import before it can execute the first line. If any one of them fails to load, the entire block never runs; it does not run halfway and then break. The scene is never created, the loop is never called, and the canvas just stays blank. The error message appears in only one place: the browser console, which mobile users have no way to see.

The rest of the page did not depend on this module. The numbers and charts used a separate set of scripts that talked to the API on the same host, so they continued working normally. The page therefore looked 80 percent functional and 20 percent broken, with nothing indicating a failure.

There were two causes of the loading failure, both producing the same symptoms. The first was that the network could not reach the CDN, whether because a LAN machine had no internet access or a mobile network could not reach that domain at the time. The second was that the browser did not understand importmap at all, such as Safari versions below 16.4, older iOS versions, and browsers embedded in apps. Without importmap support, a bare name like three could not be resolved to a file, so the module did not run either.

Before: importmap to external CDNview3d.htmlSingle pageimportmapthree -> CDNExternal CDNUnreachablemodule scriptNever runsBlank canvasNo messageNumbers and charts load from the same host, so they work while 3D stays blankAfter: modules in ./vendor/ on the same hostview3d.htmlSame single filees-module-shims+ importmap./vendor/Same hostloop() runsFirst frame__v3d_ok= trueBrowserNative importmapes-module-shimsSafari below 16.4 / old iOSNoRequiredOlder chat app browsersNoRequiredCurrent browsersYesLoads, then steps aside
The top row shows the original setup: importmap points to an external CDN. When it is unreachable, the entire module script never runs, with no message on screen. The bottom row shows the new setup: every file is in ./vendor/ on the same host as the page. The table at the bottom shows which browsers need es-module-shims.
Why It Fails Silentlyimport fails to loadCDN unreachable->module never runsThe entire block->No sceneloop never called->Blank canvasError in the console->Other scripts still runAll numbers appear

The Fix: Put the Modules in vendor on the Same Host

The rule I adopted after this was that anything the page cannot function without must live on the same host as the page. So I downloaded the files I actually used and hosted them myself.

# ดึงไฟล์ที่ใช้จริงลงมาไว้ข้างหน้าเว็บ ทำครั้งเดียวบนเครื่องที่ออกเน็ตได้
mkdir -p vendor/addons/controls
BASE=https://cdn.jsdelivr.net/npm/[email protected]
curl -sSfL -o vendor/three.module.js "$BASE/build/three.module.js"
curl -sSfL -o vendor/addons/controls/OrbitControls.js "$BASE/examples/jsm/controls/OrbitControls.js"
curl -sSfL -o vendor/es-module-shims.js https://cdn.jsdelivr.net/npm/es-module-shims/dist/es-module-shims.js

# ต้องดูก่อนว่าไฟล์ addon ที่เอามา import อะไรต่ออีกบ้าง จะได้ไม่ขาดไฟล์
grep -n "^import\|from '" vendor/addons/controls/OrbitControls.js | head

The final grep line is a step that cannot be skipped. Each file in addons has its own imports. If any are missing, the same blank area returns for a new reason. The OrbitControls I used imported only from three, so I did not need to bring in any other files. If you use another addon or another Three.js version, inspect the imports in each file all the way to the end of the chain first.

Then I changed the head of the page to this.

<!-- ของใหม่: shim มาก่อน importmap และทุก path เป็นแบบ relative -->
<script async src="./vendor/es-module-shims.js"></script>
<script type="importmap">
{ "imports": {
  "three": "./vendor/three.module.js",
  "three/addons/": "./vendor/addons/"
}}
</script>

There are three points in these four lines. First, es-module-shims adds importmap support to browsers that lack it; on browsers that already support it, it steps aside without interfering. Second, the shim itself must also be in vendor. Loading the shim from a CDN would just move the point of failure from one file to another. Third, the paths start with ./, which resolves relative to the page's location. The same file therefore works with both /app/vendor/ on the LAN server and /view3d/vendor/ on the web host, without separate conditions for each deployment.

Relative Paths Depend on the URL Used to Open the Page

On the web host, I wanted a URL without .html, so I created a view3d/ folder and placed the page inside it as index.html, letting the web server redirect /view3d to /view3d/. As a result, ./vendor/ there means /view3d/vendor/. The vendor folder must be inside that folder too, and every time I edit the page, I must upload all the files to both locations. Forgetting either one leaves two different versions of the page.

A Flag Confirming the Loop Is Running, and a Box Explaining Failures

Moving the files onto the same host fixed the cause I had found, but it did not fix the page's habit of failing silently. So I added two things. The first was a flag set when the rendering loop actually starts running.

// ใน module หลัก: ตั้งธงเมื่อวาดเฟรมได้จริง ไม่ใช่เมื่อ import สำเร็จ
function loop() {
  requestAnimationFrame(loop);
  controls.update();
  renderer.render(scene, camera);
  window.__v3d_ok = true;
}
loop();

The second was another regular script, outside the module, so it could always run even if the main module had already failed. It waits 10 seconds; if the flag is still unset, it checks the likely cause and displays a message on screen.

// สคริปต์ธรรมดา วางไว้นอก module — ทำงานได้แม้ 3D จะโหลดไม่ขึ้นเลย
(function () {
  function show(msg) {
    var e = document.getElementById('err3d');
    if (e) { e.style.display = 'block'; e.textContent = msg; }
  }

  window.addEventListener('error', function (ev) {
    var m = (ev && ev.message) || '', f = (ev && ev.filename) || '';
    if (/import|module|three|WebGL|fetch/i.test(m) || /three|module|vendor/i.test(f))
      show('3D โหลดผิดพลาด: ' + (m || f || 'unknown'));
  }, true);

  setTimeout(function () {
    if (window.__v3d_ok) return;
    var gl = null;
    try {
      var c = document.createElement('canvas');
      gl = c.getContext('webgl2') || c.getContext('webgl');
    } catch (e) {}
    var im = ('supports' in HTMLScriptElement) ? HTMLScriptElement.supports('importmap') : false;

    if (!gl) show('อุปกรณ์นี้ไม่รองรับ WebGL ลองเปิดด้วยเครื่องหรือเบราว์เซอร์อื่น');
    else if (!im && !window.importShim) show('เบราว์เซอร์ไม่รองรับ importmap และตัวช่วยโหลดไม่ขึ้น ลองเบราว์เซอร์รุ่นใหม่');
    else show('3D โหลดช้าหรือไม่ขึ้น ลองรีเฟรช หรือเปิดด้วยเบราว์เซอร์หลักของเครื่อง');
  }, 10000);
})();

The #err3d box is a div hidden in a lower corner of the screen. Its message does not fix the problem for the user; it gives them something useful to report, instead of just saying that nothing appears. The same flag also serves as an assertion point in automated tests.

2 locationsHosting the same file
1 / 5 secLAN / web polling interval
3 filesMoved into vendor
10 secWait for the flag before showing the message
16.4Safari below this needs a shim

Verifying It by Blocking the CDN Myself

The difficulty with this bug was that it never happened on my machine. I could not claim it was fixed just by opening the page myself. So I recreated a network that could not reach the CDN by having Playwright abort every request to the CDN's domain, then checking whether the 3D view still appeared.

// tools/no-cdn-check.cjs — รัน: node tools/no-cdn-check.cjs http://192.168.10.40/app/view3d.html
const { chromium } = require('playwright');

(async () => {
  const url = process.argv[2];
  const b = await chromium.launch();
  const p = await b.newPage();

  const dropped = [];
  await p.route(/cdn\.jsdelivr\.net/, r => { dropped.push(r.request().url()); return r.abort(); });

  const errs = [];
  p.on('pageerror', e => errs.push(e.message));

  await p.goto(url, { waitUntil: 'load' });
  let ok = true;
  try {
    await p.waitForFunction(() => window.__v3d_ok === true, null, { timeout: 15000 });
  } catch (e) { ok = false; }

  console.log(ok ? '[OK] 3D ขึ้นโดยไม่ต้องใช้ CDN' : '[FAIL] ธง __v3d_ok ไม่ขึ้น');
  console.log('     คำขอไป CDN ที่ถูกทิ้ง: ' + dropped.length);
  errs.forEach(e => console.log('     PAGEERROR: ' + e));
  await b.close();
  process.exit(ok && dropped.length === 0 ? 0 : 1);
})();

This script has two pass conditions: the flag must be set, and the number of aborted CDN requests must be zero. The second condition matters just as much. If even one request still goes out, something still depends on an external resource; it just happens to be something the page can survive without. Running the same test against the original file must produce FAIL before I can trust that the test actually catches this symptom.

Test Conditions Your Own Machine Has Never Encountered

A bug that depends on the user's network will never occur on a development machine with unrestricted internet access. Blocking paths with Playwright routes is the cheapest way to make my machine behave like the reporting user's machine, and it can be kept as a permanent test. There is no need to borrow anyone's phone.

Other Traps I Found on the Same Page

While working on this page, I ran into several other issues that broke it or made it appear not to update. I have collected them here because they often occur together.

Symptom Cause Fix
Adding a link button to an old page broke JS across the page The old page's main script had 3 opening tags but only 2 closing tags, so content inserted before </body> ended up inside the script Insert it after <body> instead, and always count opening and closing tags first
Clearing the view cache during active use returned 500 A compiled view file was deleted while another request was reading it Only overwrite the blade file; its updated modification time triggers recompilation automatically
Values in @media had no effect A base rule for the same selector appeared after @media and overrode it Move the base rule before @media
A position fixed button would not stay against the screen edge It was a child of an element with backdrop-filter, so its fixed positioning was relative to that parent Move the button to be a child of body
The old page still appeared after uploading The site's CDN had cached the page Append ?v= when checking, and purge that layer's cache
Headless tests returned 403 The site's bot protection rejected the headless User-Agent Set userAgent in the test context

I have already covered caching and the view cache layer by layer in the article on five cache layers. The unclosed script tags are related to the blank page caused by a function name colliding with a global: the entire script fails without the server knowing anything about it.

Another thing that helped considerably was that the LAN API allowed cross-origin requests. I could open the HTML file on my development machine and have it fetch real data from the server to drive the scene, without uploading it for every test. This is suitable for an API on a closed network that provides only read-only data. I would not enable this for an internet-facing API or one that can perform actions.

This is the sequence I now follow for every page that uses external resources.

  1. List every file the page loads, separating files on the same host from external ones.
  2. Download external resources that the page cannot function without into vendor/, along with every file they import throughout the dependency chain.
  3. Use a relative importmap and place es-module-shims before it, with the shim itself also in vendor/.
  4. Set a flag when the critical component actually works, and use a regular script outside the module to explain the cause if the flag is not set.
  5. Run a test that aborts requests to external domains. The flag must be set and the number of aborted requests must be zero.
  6. If the same file is deployed in multiple locations, check every URL after uploading, including each location's vendor folder.

My conclusion is that public CDNs are suitable for examples and experiments, but for pages that must open on networks I do not control, especially pages used on an organization's LAN, I choose to host all the files myself. Three extra files buy a page that depends on nothing beyond its own host. Whether to keep using a CDN for size or convenience depends on the project. Just include a flag and an error message box, so there is no need to guess from “nothing appears,” as I did when I went down the wrong path. If I have left anything out or made a typo, I will come back and correct it later.

Want us to set this up?

Get help with server setup, configuration, migration, or troubleshooting. Save time for the work that matters.

Get a quote

Hit something like this? Stuck somewhere?

Come trade notes on the LinuxThai board

→ Continue on the board

Comments 0

No comments yet — be the first