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)"
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
msgid "Double click on globe to go back."
msgstr ""
@ -107,6 +99,14 @@ msgstr ""
msgid "A 3D globe of our whole map"
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
#, javascript-format
msgid ""
@ -305,21 +305,6 @@ msgstr ""
msgid "Password must be shorter than 60 characters."
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
msgid "No Captcha given"
msgstr ""
@ -356,6 +341,21 @@ msgstr ""
msgid "Incorrect password!"
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
msgid "You will be automatically redirected after 15s"
msgstr ""

View File

@ -45,6 +45,14 @@ msgstr ""
msgid "Hide Hidden Canvases"
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
msgid "Error :("
msgstr ""
@ -146,14 +154,6 @@ msgstr ""
msgid "Error ${ retCode }"
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
msgid "Register New Account"
msgstr ""
@ -235,11 +235,6 @@ msgstr ""
msgid "Open Chat"
msgstr ""
#: src/components/buttons/CanvasSwitchButton.jsx:22
#: src/components/windows/index.js:19
msgid "Canvas Selection"
msgstr ""
#: src/components/buttons/ExpandMenuButton.jsx:23
msgid "Close Menu"
msgstr ""
@ -248,6 +243,11 @@ msgstr ""
msgid "Open Menu"
msgstr ""
#: src/components/buttons/CanvasSwitchButton.jsx:22
#: src/components/windows/index.js:19
msgid "Canvas Selection"
msgstr ""
#: src/components/HistorySelect.jsx:144
msgid "Loading"
msgstr ""
@ -272,16 +272,16 @@ msgstr ""
msgid "Resize"
msgstr ""
#: src/components/buttons/SettingsButton.jsx:23
#: src/components/windows/index.js:14
msgid "Settings"
msgstr ""
#: src/components/buttons/HelpButton.jsx:23
#: src/components/windows/index.js:13
msgid "Help"
msgstr ""
#: src/components/buttons/SettingsButton.jsx:23
#: src/components/windows/index.js:14
msgid "Settings"
msgstr ""
#: src/components/buttons/LogInButton.jsx:23
#: src/components/windows/index.js:15
msgid "User Area"
@ -303,10 +303,6 @@ msgstr ""
msgid "Open Palette"
msgstr ""
#: src/components/contextmenus/ChannelContextMenu.jsx:55
msgid "Mute"
msgstr ""
#: src/components/contextmenus/UserContextMenu.jsx:55
msgid "Ping"
msgstr ""
@ -319,6 +315,10 @@ msgstr ""
msgid "Block"
msgstr ""
#: src/components/contextmenus/ChannelContextMenu.jsx:55
msgid "Mute"
msgstr ""
#: src/components/windows/index.js:16
msgid "Registration"
msgstr ""
@ -742,14 +742,6 @@ msgid ""
"how the canvas was at that time."
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
msgid "Channel settings"
msgstr ""
@ -766,6 +758,14 @@ msgstr ""
msgid "You must be logged in to chat"
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:105
msgid "Could not load captcha"
@ -1181,6 +1181,28 @@ msgstr ""
msgid "Dimensions"
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
msgid "Passwords do not match."
msgstr ""
@ -1201,32 +1223,14 @@ msgstr ""
msgid "Confirm New Password"
msgstr ""
#: src/components/DeleteAccount.jsx:66
msgid "Yes, Delete My Account!"
msgstr ""
#: src/components/ChangeName.jsx:64
msgid "New Username"
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
msgid ""
"Changed Mail successfully. We sent you a verification mail, "
@ -1237,10 +1241,6 @@ msgstr ""
msgid "New Mail"
msgstr ""
#: src/components/DeleteAccount.jsx:66
msgid "Yes, Delete My Account!"
msgstr ""
#: src/components/SocialSettings.jsx:38
msgid "Block all Private Messages"
msgstr ""

View File

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

View File

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

View File

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