fix woker threads

This commit is contained in:
HF 2022-04-04 05:09:39 +02:00
parent 258fd42e68
commit 04c1099392
5 changed files with 99 additions and 96 deletions

View File

@ -83,14 +83,6 @@ msgid ""
"one (Note: you can use those links just once)" "one (Note: you can use those links just once)"
msgstr "" msgstr ""
#: src/ssr-components/Main.jsx:70
msgid "PixelPlanet.fun"
msgstr ""
#: src/ssr-components/Main.jsx:72
msgid "Place color pixels on an map styled canvas with other players online"
msgstr ""
#: src/ssr-components/Globe.jsx:44 #: src/ssr-components/Globe.jsx:44
msgid "Double click on globe to go back." msgid "Double click on globe to go back."
msgstr "" msgstr ""
@ -107,6 +99,14 @@ msgstr ""
msgid "A 3D globe of our whole map" msgid "A 3D globe of our whole map"
msgstr "" msgstr ""
#: src/ssr-components/Main.jsx:70
msgid "PixelPlanet.fun"
msgstr ""
#: src/ssr-components/Main.jsx:72
msgid "Place color pixels on an map styled canvas with other players online"
msgstr ""
#: src/core/mail.js:65 #: src/core/mail.js:65
#, javascript-format #, javascript-format
msgid "" msgid ""
@ -305,21 +305,6 @@ msgstr ""
msgid "Password must be shorter than 60 characters." msgid "Password must be shorter than 60 characters."
msgstr "" msgstr ""
#: src/routes/api/auth/verify.js:25
#: src/routes/api/auth/verify.js:32
msgid "Mail verification"
msgstr ""
#: src/routes/api/auth/verify.js:26
msgid "You are now verified :)"
msgstr ""
#: src/routes/api/auth/verify.js:32
msgid ""
"Your mail verification code is invalid or already expired :(, please "
"request a new one."
msgstr ""
#: src/routes/api/auth/register.js:33 #: src/routes/api/auth/register.js:33
msgid "No Captcha given" msgid "No Captcha given"
msgstr "" msgstr ""
@ -356,6 +341,21 @@ msgstr ""
msgid "Incorrect password!" msgid "Incorrect password!"
msgstr "" msgstr ""
#: src/routes/api/auth/verify.js:25
#: src/routes/api/auth/verify.js:32
msgid "Mail verification"
msgstr ""
#: src/routes/api/auth/verify.js:26
msgid "You are now verified :)"
msgstr ""
#: src/routes/api/auth/verify.js:32
msgid ""
"Your mail verification code is invalid or already expired :(, please "
"request a new one."
msgstr ""
#: src/ssr-components/RedirectionPage.jsx:20 #: src/ssr-components/RedirectionPage.jsx:20
msgid "You will be automatically redirected after 15s" msgid "You will be automatically redirected after 15s"
msgstr "" msgstr ""

View File

@ -45,6 +45,14 @@ msgstr ""
msgid "Hide Hidden Canvases" msgid "Hide Hidden Canvases"
msgstr "" msgstr ""
#: src/ui/renderer.js:36
msgid "Canvas Error"
msgstr ""
#: src/ui/renderer.js:37
msgid "Can't render 3D canvas, do you have WebGL2 disabled?"
msgstr ""
#: src/ui/placePixel.js:53 #: src/ui/placePixel.js:53
msgid "Error :(" msgid "Error :("
msgstr "" msgstr ""
@ -146,14 +154,6 @@ msgstr ""
msgid "Error ${ retCode }" msgid "Error ${ retCode }"
msgstr "" msgstr ""
#: src/ui/renderer.js:36
msgid "Canvas Error"
msgstr ""
#: src/ui/renderer.js:37
msgid "Can't render 3D canvas, do you have WebGL2 disabled?"
msgstr ""
#: src/actions/index.js:628 #: src/actions/index.js:628
msgid "Register New Account" msgid "Register New Account"
msgstr "" msgstr ""
@ -235,11 +235,6 @@ msgstr ""
msgid "Open Chat" msgid "Open Chat"
msgstr "" msgstr ""
#: src/components/buttons/CanvasSwitchButton.jsx:22
#: src/components/windows/index.js:19
msgid "Canvas Selection"
msgstr ""
#: src/components/buttons/ExpandMenuButton.jsx:23 #: src/components/buttons/ExpandMenuButton.jsx:23
msgid "Close Menu" msgid "Close Menu"
msgstr "" msgstr ""
@ -248,6 +243,11 @@ msgstr ""
msgid "Open Menu" msgid "Open Menu"
msgstr "" msgstr ""
#: src/components/buttons/CanvasSwitchButton.jsx:22
#: src/components/windows/index.js:19
msgid "Canvas Selection"
msgstr ""
#: src/components/HistorySelect.jsx:144 #: src/components/HistorySelect.jsx:144
msgid "Loading" msgid "Loading"
msgstr "" msgstr ""
@ -272,16 +272,16 @@ msgstr ""
msgid "Resize" msgid "Resize"
msgstr "" msgstr ""
#: src/components/buttons/SettingsButton.jsx:23
#: src/components/windows/index.js:14
msgid "Settings"
msgstr ""
#: src/components/buttons/HelpButton.jsx:23 #: src/components/buttons/HelpButton.jsx:23
#: src/components/windows/index.js:13 #: src/components/windows/index.js:13
msgid "Help" msgid "Help"
msgstr "" msgstr ""
#: src/components/buttons/SettingsButton.jsx:23
#: src/components/windows/index.js:14
msgid "Settings"
msgstr ""
#: src/components/buttons/LogInButton.jsx:23 #: src/components/buttons/LogInButton.jsx:23
#: src/components/windows/index.js:15 #: src/components/windows/index.js:15
msgid "User Area" msgid "User Area"
@ -303,10 +303,6 @@ msgstr ""
msgid "Open Palette" msgid "Open Palette"
msgstr "" msgstr ""
#: src/components/contextmenus/ChannelContextMenu.jsx:55
msgid "Mute"
msgstr ""
#: src/components/contextmenus/UserContextMenu.jsx:55 #: src/components/contextmenus/UserContextMenu.jsx:55
msgid "Ping" msgid "Ping"
msgstr "" msgstr ""
@ -319,6 +315,10 @@ msgstr ""
msgid "Block" msgid "Block"
msgstr "" msgstr ""
#: src/components/contextmenus/ChannelContextMenu.jsx:55
msgid "Mute"
msgstr ""
#: src/components/windows/index.js:16 #: src/components/windows/index.js:16
msgid "Registration" msgid "Registration"
msgstr "" msgstr ""
@ -742,14 +742,6 @@ msgid ""
"how the canvas was at that time." "how the canvas was at that time."
msgstr "" msgstr ""
#: src/components/windows/ForgotPassword.jsx:60
msgid "Sent you a mail with instructions to reset your password."
msgstr ""
#: src/components/windows/ForgotPassword.jsx:71
msgid "Enter your mail address and we will send you a new password:"
msgstr ""
#: src/components/windows/Chat.jsx:133 #: src/components/windows/Chat.jsx:133
msgid "Channel settings" msgid "Channel settings"
msgstr "" msgstr ""
@ -766,6 +758,14 @@ msgstr ""
msgid "You must be logged in to chat" msgid "You must be logged in to chat"
msgstr "" msgstr ""
#: src/components/windows/ForgotPassword.jsx:60
msgid "Sent you a mail with instructions to reset your password."
msgstr ""
#: src/components/windows/ForgotPassword.jsx:71
msgid "Enter your mail address and we will send you a new password:"
msgstr ""
#: src/components/Captcha.jsx:50 #: src/components/Captcha.jsx:50
#: src/components/Captcha.jsx:105 #: src/components/Captcha.jsx:105
msgid "Could not load captcha" msgid "Could not load captcha"
@ -1181,6 +1181,28 @@ msgstr ""
msgid "Dimensions" msgid "Dimensions"
msgstr "" msgstr ""
#: src/components/LogInForm.jsx:76
msgid "Name or Email"
msgstr ""
#: src/components/LogInForm.jsx:87
msgid "LogIn"
msgstr ""
#: src/components/UserMessages.jsx:28
msgid ""
"Please verify your mail address \n"
"or your account could get deleted after a few days."
msgstr ""
#: src/components/UserMessages.jsx:49
msgid "A new verification mail is getting sent to you."
msgstr ""
#: src/components/UserMessages.jsx:53
msgid "Click here to request a new verification mail."
msgstr ""
#: src/components/ChangePassword.jsx:22 #: src/components/ChangePassword.jsx:22
msgid "Passwords do not match." msgid "Passwords do not match."
msgstr "" msgstr ""
@ -1201,32 +1223,14 @@ msgstr ""
msgid "Confirm New Password" msgid "Confirm New Password"
msgstr "" msgstr ""
#: src/components/DeleteAccount.jsx:66
msgid "Yes, Delete My Account!"
msgstr ""
#: src/components/ChangeName.jsx:64 #: src/components/ChangeName.jsx:64
msgid "New Username" msgid "New Username"
msgstr "" msgstr ""
#: src/components/UserMessages.jsx:28
msgid ""
"Please verify your mail address \n"
"or your account could get deleted after a few days."
msgstr ""
#: src/components/UserMessages.jsx:49
msgid "A new verification mail is getting sent to you."
msgstr ""
#: src/components/UserMessages.jsx:53
msgid "Click here to request a new verification mail."
msgstr ""
#: src/components/LogInForm.jsx:76
msgid "Name or Email"
msgstr ""
#: src/components/LogInForm.jsx:87
msgid "LogIn"
msgstr ""
#: src/components/ChangeMail.jsx:59 #: src/components/ChangeMail.jsx:59
msgid "" msgid ""
"Changed Mail successfully. We sent you a verification mail, " "Changed Mail successfully. We sent you a verification mail, "
@ -1237,10 +1241,6 @@ msgstr ""
msgid "New Mail" msgid "New Mail"
msgstr "" msgstr ""
#: src/components/DeleteAccount.jsx:66
msgid "Yes, Delete My Account!"
msgstr ""
#: src/components/SocialSettings.jsx:38 #: src/components/SocialSettings.jsx:38
msgid "Block all Private Messages" msgid "Block all Private Messages"
msgstr "" msgstr ""

View File

@ -114,7 +114,7 @@ function tileFileName(canvasTileFolder, cell) {
/* /*
* @param canvasSize dimension of the canvas (pixels width/height) * @param canvasSize dimension of the canvas (pixels width/height)
* @param redisCanvas Redis Canvas object * @param redisClient redis instance
* @param canvasId id of the canvas * @param canvasId id of the canvas
* @param canvasTileFolder root folder where to save tiles * @param canvasTileFolder root folder where to save tiles
* @param palette Palette to use * @param palette Palette to use
@ -122,13 +122,13 @@ function tileFileName(canvasTileFolder, cell) {
* @return true if successfully created tile, false if tile empty * @return true if successfully created tile, false if tile empty
*/ */
export async function createZoomTileFromChunk( export async function createZoomTileFromChunk(
redisCanvas: Object, redisClient,
canvasSize, canvasSize,
canvasId, canvasId,
canvasTileFolder, canvasTileFolder,
palette, palette,
cell, cell,
): boolean { ) {
const [x, y] = cell; const [x, y] = cell;
const maxTiledZoom = getMaxTiledZoom(canvasSize); const maxTiledZoom = getMaxTiledZoom(canvasSize);
const tileRGBBuffer = new Uint8Array( const tileRGBBuffer = new Uint8Array(
@ -142,7 +142,9 @@ export async function createZoomTileFromChunk(
let chunk = null; let chunk = null;
for (let dy = 0; dy < TILE_ZOOM_LEVEL; dy += 1) { for (let dy = 0; dy < TILE_ZOOM_LEVEL; dy += 1) {
for (let dx = 0; dx < TILE_ZOOM_LEVEL; dx += 1) { for (let dx = 0; dx < TILE_ZOOM_LEVEL; dx += 1) {
chunk = await redisCanvas.getChunk(canvasId, xabs + dx, yabs + dy); chunk = await redisClient.getAsync(
`ch:${canvasId}:${xabs + dx}:${yabs + dy}`,
);
if (!chunk || chunk.length !== TILE_SIZE * TILE_SIZE) { if (!chunk || chunk.length !== TILE_SIZE * TILE_SIZE) {
na.push([dx, dy]); na.push([dx, dy]);
continue; continue;
@ -193,7 +195,7 @@ export async function createZoomedTile(
canvasTileFolder, canvasTileFolder,
palette, palette,
cell, cell,
): boolean { ) {
const tileRGBBuffer = new Uint8Array( const tileRGBBuffer = new Uint8Array(
TILE_SIZE * TILE_SIZE * TILE_ZOOM_LEVEL * TILE_ZOOM_LEVEL * 3, TILE_SIZE * TILE_SIZE * TILE_ZOOM_LEVEL * TILE_ZOOM_LEVEL * 3,
); );
@ -277,7 +279,7 @@ export async function createEmptyTile(
/* /*
* created 4096x4096 texture of default canvas * created 4096x4096 texture of default canvas
* @param redisCanvas Redis Canvas object * @param redisClient redis instance
* @param canvasId numberical Id of canvas * @param canvasId numberical Id of canvas
* @param canvasSize size of canvas * @param canvasSize size of canvas
* @param canvasTileFolder root folder where to save texture * @param canvasTileFolder root folder where to save texture
@ -285,7 +287,7 @@ export async function createEmptyTile(
* *
*/ */
export async function createTexture( export async function createTexture(
redisCanvas: Object, redisClient,
canvasId, canvasId,
canvasSize, canvasSize,
canvasTileFolder, canvasTileFolder,
@ -315,7 +317,7 @@ export async function createTexture(
} else { } else {
for (let dy = 0; dy < amount; dy += 1) { for (let dy = 0; dy < amount; dy += 1) {
for (let dx = 0; dx < amount; dx += 1) { for (let dx = 0; dx < amount; dx += 1) {
chunk = await redisCanvas.getChunk(canvasId, dx, dy); chunk = await redisClient.getAsync(`ch:${canvasId}:${dx}:${dy}`);
if (!chunk || chunk.length !== TILE_SIZE * TILE_SIZE) { if (!chunk || chunk.length !== TILE_SIZE * TILE_SIZE) {
na.push([dx, dy]); na.push([dx, dy]);
continue; continue;
@ -353,7 +355,7 @@ export async function createTexture(
/* /*
* Create all tiles * Create all tiles
* @param redisCanvas Redis Canvas object * @param redisClient redis instance
* @param canvasSize dimension of the canvas (pixels width/height) * @param canvasSize dimension of the canvas (pixels width/height)
* @param canvasId id of the canvas * @param canvasId id of the canvas
* @param canvasTileFolder root foler where to save tiles * @param canvasTileFolder root foler where to save tiles
@ -361,12 +363,12 @@ export async function createTexture(
* @param force overwrite existing tiles * @param force overwrite existing tiles
*/ */
export async function initializeTiles( export async function initializeTiles(
redisCanvas: Object, redisClient,
canvasSize, canvasSize,
canvasId, canvasId,
canvasTileFolder, canvasTileFolder,
palette, palette,
force: boolean = false, force = false,
) { ) {
console.log( console.log(
`Tiling: Initializing tiles in ${canvasTileFolder}, forceint = ${force}`, `Tiling: Initializing tiles in ${canvasTileFolder}, forceint = ${force}`,
@ -390,7 +392,7 @@ export async function initializeTiles(
const filename = `${canvasTileFolder}/${zoom}/${cx}/${cy}.png`; const filename = `${canvasTileFolder}/${zoom}/${cx}/${cy}.png`;
if (force || !fs.existsSync(filename)) { if (force || !fs.existsSync(filename)) {
const ret = await createZoomTileFromChunk( const ret = await createZoomTileFromChunk(
redisCanvas, redisClient,
canvasSize, canvasSize,
canvasId, canvasId,
canvasTileFolder, canvasTileFolder,
@ -436,7 +438,7 @@ export async function initializeTiles(
} }
// create snapshot texture // create snapshot texture
await createTexture( await createTexture(
redisCanvas, redisClient,
canvasId, canvasId,
canvasSize, canvasSize,
canvasTileFolder, canvasTileFolder,

View File

@ -4,6 +4,7 @@
*/ */
import fs from 'fs'; import fs from 'fs';
import { Worker } from 'worker_threads';
import logger from './logger'; import logger from './logger';
// eslint-disable-next-line import/no-unresolved // eslint-disable-next-line import/no-unresolved

View File

@ -5,8 +5,8 @@
/* eslint-disable no-console */ /* eslint-disable no-console */
import { isMainThread, parentPort } from 'worker_threads'; import { isMainThread, parentPort } from 'worker_threads';
import RedisCanvas from '../data/models/RedisCanvas';
import redisClient from '../data/redis';
import { import {
createZoomTileFromChunk, createZoomTileFromChunk,
createZoomedTile, createZoomedTile,
@ -24,16 +24,16 @@ parentPort.on('message', async (msg) => {
const { task, args } = msg; const { task, args } = msg;
switch (task) { switch (task) {
case 'createZoomTileFromChunk': case 'createZoomTileFromChunk':
createZoomTileFromChunk(RedisCanvas, ...args); createZoomTileFromChunk(redisClient, ...args);
break; break;
case 'createZoomedTile': case 'createZoomedTile':
createZoomedTile(...args); createZoomedTile(...args);
break; break;
case 'createTexture': case 'createTexture':
createTexture(RedisCanvas, ...args); createTexture(redisClient, ...args);
break; break;
case 'initializeTiles': case 'initializeTiles':
await initializeTiles(RedisCanvas, ...args); await initializeTiles(redisClient, ...args);
parentPort.postMessage('Done!'); parentPort.postMessage('Done!');
break; break;
default: default: