Window is not defined when webworkerservice used by another thread
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 49/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- javascript, wasm
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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>());
- Ngôn ngữ chính
- JavaScript
- Star
- 3
- Fork
- 0
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của LostBeard/SpawnDev.SpawnJS.WebWorkers
-
OPFS example?Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
LostBeard/SpawnDev.SpawnJS.WebWorkers#2 · 4 bình luận ·
-
Rollup fails with errorCó thể làm lại được @LostBeard đã nhận 76 ngày trước và không có pull request nào đang mở. Đang mởgood first issue
LostBeard/SpawnDev.SpawnJS.WebWorkers#1 · 13 bình luận · 1 người được giao ·
Tất cả issue của LostBeard/SpawnDev.SpawnJS.WebWorkers
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
mongoosejs/mquery#142 ·
-
Site Suggestion: bullseyeĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Add toro4n to the data modeling toolsCó thể đã có người làm @henriklantzhedstrom-prog đã nhận hôm nay. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 62/100
neo4j/docs-getting-started#546 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 25 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
libnativeapi/nativeapi#21 ·