CesiumGS / cesium

An open-source JavaScript library for world-class 3D globes and maps :earth_americas:
https://cesium.com/cesiumjs/
Apache License 2.0
13.03k stars 3.51k forks source link

`Uncaught TypeError: Cannot read properties of null (reading 'createElement')` constructing Viewer in Brave #11253

Closed matthewelmer closed 1 year ago

matthewelmer commented 1 year ago

Sandcastle example: https://sandcastle.cesium.com/index.html#c=bYzLCsIwFER/5ZKVgiS4Ni1Ct4ILwVU2aXrV4G1S8mipX29bERRdzsw5Y7yLCXqLAwYowOEAFUabW35eupViZsmVd0lbh0Gx9U45tmEyppGwVA5gb9vOhwQ50IpzkbDtSCeMos7mjombGGdJirciG9uDbYo/72BIxzgtl0x0sg9UrJRi4r808rqx7nrsMZAeZ+S2LQ+vknMuxRR/reQ91Tp8PD4B

Browser: Brave Version 1.50.125 Chromium: 112.0.5615.165 (Official Build) (64-bit)](https://brave.com/latest/)

Operating System: Linux Mint 21.1 Cinnamon

If I create index.html with the following contents:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <script src="https://cesium.com/downloads/cesiumjs/releases/1.102/Build/Cesium/Cesium.js"></script>
  <link href="https://cesium.com/downloads/cesiumjs/releases/1.102/Build/Cesium/Widgets/widgets.css" rel="stylesheet">
</head>
<body>
  <div id="cesiumContainer" class="fullSize"></div>
</body>
<script src="main.js"></script>
</html>

And main.js with the following contents:

Cesium.Ion.defaultAccessToken = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
let viewer = new Cesium.Viewer("cesiumContainer");

And try to open index.html in Brave, I get the following error in my console:

Uncaught TypeError: Cannot read properties of null (reading 'createElement')
  at HTMLIFrameElement.<anonymous> (Cesium.js:14440:41393)

Although seemingly benign, it's an error and not a warning, so it absolutely shouldn't happen.

I even tried the following in main.js to no avail:

onload = (event) => {
  Cesium.Ion.defaultAccessToken = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
  let viewer = new Cesium.Viewer("cesiumContainer");
}
ggetz commented 1 year ago

Thanks for the report @matthewelmer.

To narrow down the cause of the error, I would suggest using the unminified version of CesiumJS Build/CesiumUnminified/Cesium.js and the source map Build/CesiumUnminified/Cesium.js.map for a more helpful stack trace.

matthewelmer commented 1 year ago

I'll get on that ASAP (might be some weeks).

matthewelmer commented 1 year ago

I instead hosted a local https server, and now I don't get that error (this also allows me to access local files by facilitating CORS!)

Here are the two easiest ways for those interested: