Skip to content

Commit 3ffc596

Browse files
committed
chore: remove debugging code
1 parent febf816 commit 3ffc596

File tree

6 files changed

+23
-153
lines changed

6 files changed

+23
-153
lines changed

.github/workflows/test-pr.yml

Lines changed: 8 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Test Pull Requests To Master (Node 20+)
1+
name: Test Pull Requests To Master (Node 17.0+)
22

33
on:
44
push:
@@ -11,7 +11,6 @@ on:
1111
jobs:
1212
build:
1313
runs-on: ubuntu-latest
14-
timeout-minutes: 10
1514
strategy:
1615
matrix:
1716
node-version: [20.x, 22.x, 24.x]
@@ -28,51 +27,19 @@ jobs:
2827
npm --version
2928
- name: ci install
3029
run: npm ci
31-
- name: setup virtual display
32-
run: |
33-
sudo apt-get update
34-
sudo apt-get install -y xvfb
35-
export DISPLAY=:99
36-
Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
37-
3830
- name: build
3931
run: npm run build --if-present
4032
env:
4133
CI: true
4234
NODE_OPTIONS: --openssl-legacy-provider # necessary for webpack v4 in node 17+
4335
- name: module test
4436
run: npm run test:module
45-
- name: debug environment info
46-
run: |
47-
echo "=== Environment Info ==="
48-
echo "Node version: $(node --version)"
49-
echo "NPM version: $(npm --version)"
50-
echo "OS: $(uname -a)"
51-
echo "Available memory: $(free -h || echo 'N/A')"
52-
echo "Available disk: $(df -h . || echo 'N/A')"
53-
echo "Display info: $DISPLAY"
54-
echo "Xvfb check: $(which Xvfb || echo 'Xvfb not found')"
55-
echo "Chrome check: $(which google-chrome || which chromium-browser || echo 'Chrome not found')"
56-
57-
- name: try single cypress test first
58-
run: timeout 120 npm run cypress:debug || echo "Single Cypress test timed out or failed"
59-
env:
60-
DEBUG: cypress:*
61-
CYPRESS_DEBUG: 1
62-
DISPLAY: :99
63-
64-
- name: try full cypress tests if single test works
65-
if: success()
66-
run: timeout 300 npm run cypress:run || echo "Full Cypress tests timed out or failed"
67-
env:
68-
DEBUG: cypress:*
69-
CYPRESS_DEBUG: 1
70-
DISPLAY: :99
71-
72-
- name: run node tests only if cypress failed
73-
if: failure()
74-
run: npx cross-env NODE_ENV=test BUILD_ENV=development ts-mocha -p test/tsconfig.json src/**/test/node/*.spec.* src/**/test/*.spec.* test/integration/integration.spec.ts
37+
- name: run all code tests
38+
run: npm test
7539
- name: test package import
76-
run: npm run test:import
40+
run: |
41+
npm install ts-node @std/esm
42+
npm run test:import
7743
- name: test package require
78-
run: npm run test:require
44+
run: |
45+
npm run test:require

configs/webpack.config.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,7 @@ module.exports = {
4747
}),
4848
new webpack.NormalModuleReplacementPlugin(/..\/input\/frame_grabber/, '../input/frame_grabber_browser.js'),
4949
new webpack.NormalModuleReplacementPlugin(/input_stream[/\\]input_stream$/, (resource) => {
50-
console.log('=== WEBPACK REPLACEMENT DEBUG ===');
51-
console.log('Original request:', resource.request);
52-
console.log('Context:', resource.context);
5350
resource.request = resource.request.replace(/input_stream$/, 'input_stream_browser');
54-
console.log('Replaced with:', resource.request);
5551
}),
5652
],
5753
optimization: {

cypress.config.ts

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -4,60 +4,10 @@ export default defineConfig({
44
video: false,
55
screenshotOnRunFailure: false,
66
trashAssetsBeforeRuns: true,
7-
chromeWebSecurity: false,
8-
watchForFileChanges: false,
97
e2e: {
108
// We've imported your old cypress plugins here.
119
// You may want to clean this up later by importing these.
1210
setupNodeEvents(on, config) {
13-
// Add browser launch arguments for CI environments
14-
on('before:browser:launch', (browser, launchOptions) => {
15-
console.log(`Launching ${browser.name} browser (headless: ${browser.isHeadless})`)
16-
17-
if (browser.name === 'chrome' || browser.name === 'chromium') {
18-
// Chrome/Chromium args for CI environments
19-
launchOptions.args.push('--disable-dev-shm-usage')
20-
launchOptions.args.push('--no-sandbox')
21-
launchOptions.args.push('--disable-gpu')
22-
launchOptions.args.push('--disable-software-rasterizer')
23-
launchOptions.args.push('--disable-background-timer-throttling')
24-
launchOptions.args.push('--disable-renderer-backgrounding')
25-
launchOptions.args.push('--disable-features=TranslateUI')
26-
launchOptions.args.push('--disable-backgrounding-occluded-windows')
27-
launchOptions.args.push('--disable-web-security')
28-
launchOptions.args.push('--allow-running-insecure-content')
29-
}
30-
31-
if (browser.name === 'electron') {
32-
// Electron-specific args for CI environments
33-
launchOptions.args.push('--disable-dev-shm-usage')
34-
launchOptions.args.push('--no-sandbox')
35-
launchOptions.args.push('--disable-gpu')
36-
launchOptions.args.push('--disable-software-rasterizer')
37-
launchOptions.args.push('--disable-background-timer-throttling')
38-
launchOptions.args.push('--disable-renderer-backgrounding')
39-
launchOptions.args.push('--disable-features=TranslateUI')
40-
launchOptions.args.push('--disable-backgrounding-occluded-windows')
41-
}
42-
43-
return launchOptions
44-
})
45-
46-
// Note: after:browser:launch is not a valid event in Cypress 13.1.0
47-
48-
// Test run event handlers for CI debugging if needed
49-
on('before:run', () => {
50-
console.log('Starting Cypress test run')
51-
})
52-
53-
on('after:run', (results) => {
54-
if (results) {
55-
console.log(`Test run completed: ${(results as any).totalPassed || 0} passed, ${results.totalFailed || 0} failed`)
56-
}
57-
})
58-
59-
// Task handler is already set up in plugins/index.js
60-
6111
return require('./cypress/plugins/index.js')(on, config)
6212
},
6313
},

cypress/plugins/index.js

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,35 +21,14 @@ module.exports = (on, config) => {
2121
config.env = config.env || {};
2222
config.env.BUILD_ENV = 'production';
2323

24-
// Always apply webpack config for Cypress (both development and test environments)
2524
if (process.env.NODE_ENV === 'test' || process.env.NODE_ENV === 'development') {
26-
const webpackConfig = require('../../configs/webpack.config');
27-
console.log('=== CYPRESS WEBPACK CONFIG DEBUG ===');
28-
console.log('Number of plugins:', webpackConfig.plugins ? webpackConfig.plugins.length : 0);
29-
console.log('Has plugins:', !!webpackConfig.plugins);
30-
if (webpackConfig.plugins) {
31-
webpackConfig.plugins.forEach((plugin, i) => {
32-
console.log(`Plugin ${i}:`, plugin.constructor.name);
33-
});
34-
}
35-
3625
const webpackOptions = {
37-
webpackOptions: webpackConfig,
26+
webpackOptions: require('../../configs/webpack.config'),
3827
watchOptions: {},
3928
};
4029
on('file:preprocessor', webpack(webpackOptions));
41-
// on('file:preprocessor', webpack());
42-
// require('@cypress/code-coverage/task')(on, config);
4330
}
4431

45-
// Task handler for potential debugging
46-
on('task', {
47-
log(message) {
48-
console.log('CYPRESS LOG:', message)
49-
return null
50-
}
51-
})
52-
5332
// on('file:preprocessor', require('@cypress/code-coverage/use-babelrc'));
5433
return config;
5534
};

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,14 @@
6363
"coverage:node": "// DOES NOT WORK YET // npx cross-env NODE_ENV=test BUILD_ENV=development nyc --no-clean ts-mocha -p test/tsconfig.json src/**/test/node/*.spec.* src/**/test/*.spec.*",
6464
"coverage": "npm run cypress:run",
6565
"cypress:open": "npx cross-env NODE_ENV=development BUILD_ENV=development cypress open --env BUILD_ENV=development",
66-
"cypress:run": "npx cross-env NODE_ENV=development BUILD_ENV=development DEBUG=cypress:* cypress run --env BUILD_ENV=development --reporter spec",
66+
"cypress:run": "npx cross-env NODE_ENV=development BUILD_ENV=development cypress run --env BUILD_ENV=development",
6767
"test:browser-specific": "NOT WORKING -- something like npx cypress run --config testFiles=[browser]",
6868
"test:browser-universal": "NOT WORKING -- something like npx cypress run --config testFiles=[universal]",
6969
"test:browser-all": "npm run cypress:run",
7070
"test:import": "mocha test/test-import.mjs",
7171
"test:node": "npx cross-env NODE_ENV=test ts-mocha -p test/tsconfig.json src/**/test/node/*.spec.* src/**/test/*.spec.* test/integration/integration.spec.ts",
7272
"test:require": "mocha test/test-require",
7373
"test:module": "npm run test:require && npm run test:import",
74-
"cypress:debug": "npx cross-env NODE_ENV=development BUILD_ENV=development DEBUG=cypress:* cypress run --env BUILD_ENV=development --spec 'cypress/e2e/browser.cy.ts'",
7574
"test": "npm run cypress:run && npx cross-env NODE_ENV=test BUILD_ENV=development ts-mocha -p test/tsconfig.json src/**/test/node/*.spec.* src/**/test/*.spec.* test/integration/integration.spec.ts",
7675
"build:dev": "npx cross-env NODE_ENV=development BUILD_ENV=development webpack --config configs/webpack.config.js",
7776
"build:prod": "npx cross-env NODE_ENV=production BUILD_ENV=production webpack --config configs/webpack.config.min.js",

src/locator/barcode_locator.js

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -89,37 +89,16 @@ function initCanvas() {
8989
if (_config.useWorker || typeof document === 'undefined') {
9090
return;
9191
}
92-
93-
try {
94-
_canvasContainer.dom.binary = document.createElement('canvas');
95-
_canvasContainer.dom.binary.className = 'binaryBuffer';
96-
if (ENV.development && _config.debug.showCanvas === true) {
97-
const debugElement = document.querySelector('#debug');
98-
if (debugElement) {
99-
debugElement.appendChild(_canvasContainer.dom.binary);
100-
}
101-
}
102-
const willReadFrequently = !!_config.willReadFrequently;
103-
console.warn('* initCanvas willReadFrequently', willReadFrequently, _config);
104-
_canvasContainer.ctx.binary = _canvasContainer.dom.binary.getContext('2d', { willReadFrequently });
105-
106-
// Test if canvas context is working by trying a basic operation
107-
if (_canvasContainer.ctx.binary) {
108-
_canvasContainer.ctx.binary.fillStyle = 'black';
109-
} else {
110-
console.warn('* Canvas context creation failed - likely headless environment issue');
111-
}
112-
} catch (error) {
113-
console.warn('* Canvas creation failed in headless environment:', error);
114-
// Gracefully continue without canvas - barcode detection can still work without debug canvas
115-
_canvasContainer.dom.binary = null;
116-
_canvasContainer.ctx.binary = null;
117-
}
118-
119-
if (_canvasContainer.dom.binary) {
120-
_canvasContainer.dom.binary.width = _binaryImageWrapper.size.x;
121-
_canvasContainer.dom.binary.height = _binaryImageWrapper.size.y;
92+
_canvasContainer.dom.binary = document.createElement('canvas');
93+
_canvasContainer.dom.binary.className = 'binaryBuffer';
94+
if (ENV.development && _config.debug.showCanvas === true) {
95+
document.querySelector('#debug').appendChild(_canvasContainer.dom.binary);
12296
}
97+
const willReadFrequently = !!_config.willReadFrequently;
98+
console.warn('* initCanvas willReadFrequently', willReadFrequently, _config);
99+
_canvasContainer.ctx.binary = _canvasContainer.dom.binary.getContext('2d', { willReadFrequently });
100+
_canvasContainer.dom.binary.width = _binaryImageWrapper.size.x;
101+
_canvasContainer.dom.binary.height = _binaryImageWrapper.size.y;
123102
}
124103

125104
/**
@@ -144,7 +123,7 @@ function boxFromPatches(patches) {
144123
for (i = 0; i < patches.length; i++) {
145124
patch = patches[i];
146125
overAvg += patch.rad;
147-
if (ENV.development && _config.debug.showPatches && _canvasContainer.ctx.binary) {
126+
if (ENV.development && _config.debug.showPatches) {
148127
ImageDebug.drawRect(patch.pos, _subImageWrapper.size, _canvasContainer.ctx.binary, { color: 'red' });
149128
}
150129
}
@@ -165,7 +144,7 @@ function boxFromPatches(patches) {
165144
vec2.transformMat2(patch.box[j], patch.box[j], transMat);
166145
}
167146

168-
if (ENV.development && _config.debug.boxFromPatches.showTransformed && _canvasContainer.ctx.binary) {
147+
if (ENV.development && _config.debug.boxFromPatches.showTransformed) {
169148
ImageDebug.drawPath(patch.box, { x: 0, y: 1 }, _canvasContainer.ctx.binary, { color: '#99ff00', lineWidth: 2 });
170149
}
171150
}
@@ -191,7 +170,7 @@ function boxFromPatches(patches) {
191170

192171
box = [[minx, miny], [maxx, miny], [maxx, maxy], [minx, maxy]];
193172

194-
if (ENV.development && _config.debug.boxFromPatches.showTransformedBox && _canvasContainer.ctx.binary) {
173+
if (ENV.development && _config.debug.boxFromPatches.showTransformedBox) {
195174
ImageDebug.drawPath(box, { x: 0, y: 1 }, _canvasContainer.ctx.binary, { color: '#ff0000', lineWidth: 2 });
196175
}
197176

@@ -219,7 +198,7 @@ function boxFromPatches(patches) {
219198
function binarizeImage() {
220199
otsuThreshold(_currentImageWrapper, _binaryImageWrapper);
221200
_binaryImageWrapper.zeroBorder();
222-
if (ENV.development && _config.debug.showCanvas && _canvasContainer.dom.binary) {
201+
if (ENV.development && _config.debug.showCanvas) {
223202
_binaryImageWrapper.show(_canvasContainer.dom.binary, 255);
224203
}
225204
}

0 commit comments

Comments
 (0)