kaplay icon indicating copy to clipboard operation
kaplay copied to clipboard

bug: Cannot read properties of null (reading 'drawingBufferWidth') when using KaPlay in NW.js

Open fractalpublic opened this issue 1 year ago • 6 comments

Bug Description

The error TypeError: Cannot read properties of null (reading 'drawingBufferWidth') is thrown when using KAPLAY (and Kaboom) in NW.js.

The error is thrown at initGfx (gfx.ts:562:15) & at KAPLAY (kaboom.ts:444:17). This error was not being thrown with original Kaboom prior to Kaboom's depreciation. After Kaboom's depreciation, both Kaboom and KAPLAY throw this error. My original code has not changed a bit.

Version

Latest from CDN

To Reproduce

Steps to reproduce the behavior:

  1. Create a normal NW.js setup.
  2. Write out your main HTML file as follows:
<html>
<head>
 <link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<script type="module">
function checkInternetConnection() {
  fetch('https://www.google.com', { mode: 'no-cors' })
    .then(response => {
      if (!response.ok && response.type !== 'opaque') {
        window.location.href = 'offline.html';
        // plain offline HTML file does render
      }
    })
    .catch(error => {
	window.location.href = 'offline.html';
      console.error('Error checking internet connection:', error);
    });
}
checkInternetConnection();

 import kaplay from "https://unpkg.com/[email protected]/dist/kaboom.mjs";
 // does import correctly. just throws error during initialization of rendering
 kaplay();
</script>
</body>
</html>
  1. Drag package.json on top of nw.exe to run the app, or use a batch file to it for you, like me.

Expected behavior

KAPLAY not erroring out and actually working...

Screenshots

image image

fractalpublic avatar Jul 17 '24 02:07 fractalpublic

is this only NW.JS or does it throw in Electron Tauri and Web

niceEli avatar Jul 17 '24 02:07 niceEli

is this only NW.JS or does it throw in Electron Tauri and Web

Haven't tried in Electron cause in my opinion it's a RAM hog and not suitable for my project. The others I haven't even thought of or used yet. The HTML file runs fine when opened in regular Google Chrome.

fractalpublic avatar Jul 17 '24 02:07 fractalpublic

Can you try with the master version? npm i github:marklovers/kaplay

lajbel avatar Jul 17 '24 12:07 lajbel

Can you try with the master version? npm i github:marklovers/kaplay

I'll try once I get out of bed today.

fractalpublic avatar Jul 17 '24 13:07 fractalpublic

Out of bed but will be a little bit delayed. Computer just crashed because Chrome and the other processes I was running decided to take up more RAM than the computer could take. I really need to get myself a better PC

fractalpublic avatar Jul 17 '24 13:07 fractalpublic

I see, no problem hh. We released recently alpha 18, if you can try it, cool. If not I will when I got time

lajbel avatar Jul 18 '24 21:07 lajbel

Closing for now, maybe a build problem? Please reopen if any other advances

lajbel avatar Sep 24 '24 20:09 lajbel