Window is not defined when webworkerservice used by another thread
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 49/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- javascript, wasm
Direzione di ricerca
Start with the browser service registration and initialization flow shown in the issue, especially the calls to AddWebWorkerService and StartBackgroundServices, then trace how WebWorkerService accesses the global scope when requested from another thread. Reproduce the failure through the Avalonia UI thread and check whether OPFS calls work there. Done means the service can be accessed from that thread without “Window is not defined” and OPFS calls function.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Attempting to get the web worker service throws with "Window is not defined"
I can fix two of the errors by replacing webWorkerService.GlobalScope == GlobalScope.Window ? 2 : 0 with 0
however, this does not fix functionality, and any calls to OPFS will still throw.
This code gets run by the Avalonia UI thread calling OnFrameworkInitializationCompleted (because my initialization requires async for many things)
Due to this, getting the WebWorkerService and attempting to use it will throw that error in the JS console it seems.
If I move the worker init code outside of the pipeline, I can use it however I like, but the second it is accessed via another thread (such as the Avalonia UI thread), it will throw.
(flow:)
- Main
- AppBuilder
- UniScanApp.Initialize() (called by Avalonia)
- OnFrameworkInitializationCompleted (called by Avalonia)
_ = InitializationPipeline.RunAsync(this);(runs a ton of tasks to initialize everything in a specific order)- The following code:
(ALSO VIEWABLE HERE: https://github.com/UniScanProject/UniScan/tree/main/src/Client/UniScan.Client.App.Platform.Browser/Program.cs)
IServiceCollection browserServices = new ServiceCollection();
browserServices.AddSpawnJSRuntime(out SpawnJSRuntime runtime);
browserServices.AddWebWorkerService(webWorkerService =>
{
webWorkerService.TaskPool.MaxPoolSize = -1;
webWorkerService.TaskPool.PoolSize = webWorkerService.GlobalScope == GlobalScope.Window ? 2 : 0;
});
browserServices.AddSingleton<BrowserDirectoryManager>();
browserServices.AddSingleton<BrowserFileManager>();
browserServices.AddSingleton<IOPFSWorkerService, OPFSWorkerService>();
IServiceProvider browserServiceProvider = browserServices.BuildServiceProvider();
await browserServiceProvider.StartBackgroundServices();
ctx.StandardPaths = new BrowserPaths();
ctx.SerilogInitializer = new BrowserPlatformSerilogInitializer(UniScan.Core.Constants.ConsoleOutputTemplate);
ctx.FileManager = browserServiceProvider.GetRequiredService<BrowserFileManager>();
ctx.DirectoryManager = browserServiceProvider.GetRequiredService<BrowserDirectoryManager>();
ctx.ServiceCollection.AddSingleton(runtime);
ctx.ServiceCollection.AddSingleton<WebWorkerService>(_ => browserServiceProvider.GetRequiredService<WebWorkerService>());
ctx.ServiceCollection.AddSingleton<IPlatformStandardPaths>(_ => ctx.StandardPaths);
ctx.ServiceCollection.AddSingleton<IPlatformSerilogInitializer>(_ => ctx.SerilogInitializer);
ctx.ServiceCollection.AddSingleton<IPlatformDirectoryManager>(_ => ctx.DirectoryManager);
ctx.ServiceCollection.AddSingleton<IPlatformFileManager>(_ => ctx.FileManager);
ctx.ServiceCollection.AddSingleton<IOPFSWorkerService>(_ => browserServiceProvider.GetRequiredService<IOPFSWorkerService>());
- Lingua principale
- JavaScript
- Stelle
- 3
- Fork
- 0
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di LostBeard/SpawnDev.SpawnJS.WebWorkers
-
OPFS example?Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
LostBeard/SpawnDev.SpawnJS.WebWorkers#2 · 4 commenti ·
-
Rollup fails with errorForse di nuovo libera @LostBeard l’ha presa 81 giorni fa e non c’è nessuna pull request aperta. Apertagood first issue
LostBeard/SpawnDev.SpawnJS.WebWorkers#1 · 13 commenti · 1 assegnatario ·
Tutte le issue di LostBeard/SpawnDev.SpawnJS.WebWorkers
Issue simili
-
stringify escapes leading digits in pseudo-class arguments (:nth-child(1) becomes :nth-child(\31 ))Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
digitalbazaar/forge#1170 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
getgrav/grav-plugin-form#664 ·
-
bug web-ui
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
jenkinsci/jenkins#27705 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno