Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overhaul of RTL plugin loading sequence #3728

Merged
merged 38 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
251751e
fire pluginStateChange only if at least one receiver changed plugin s…
zhangyiatmicrosoft Feb 20, 2024
4009780
draft
zhangyiatmicrosoft Feb 27, 2024
b1c844b
Merge branch 'maplibre:main' into fix-plugin-msg
zhangyiatmicrosoft Mar 1, 2024
322317e
fixes
zhangyiatmicrosoft Mar 1, 2024
e8d23e4
all ut pass
zhangyiatmicrosoft Mar 1, 2024
04e5e2f
test cases
zhangyiatmicrosoft Mar 1, 2024
7719c78
change log
zhangyiatmicrosoft Mar 1, 2024
34696ae
worker tests
zhangyiatmicrosoft Mar 1, 2024
30a512e
add change in style.ts
zhangyiatmicrosoft Mar 2, 2024
f7108af
update style test
zhangyiatmicrosoft Mar 2, 2024
646369f
update UT
zhangyiatmicrosoft Mar 2, 2024
221f67e
Update src/source/rtl_text_plugin_main_thread.test.ts
HarelM Mar 2, 2024
c9e3ba6
PR comments
zhangyiatmicrosoft Mar 4, 2024
12b0466
Merge branch 'fix-plugin-msg' of https://github.com/zhangyiatmicrosof…
zhangyiatmicrosoft Mar 4, 2024
834db54
Merge branch 'main' into fix-plugin-msg
HarelM Mar 4, 2024
c586e80
PR comments
zhangyiatmicrosoft Mar 4, 2024
8cd6a8b
dup lazyLoad() calls
zhangyiatmicrosoft Mar 4, 2024
025ef4d
multiple
zhangyiatmicrosoft Mar 4, 2024
2470cc9
Merge branch 'fix-plugin-msg' of https://github.com/zhangyiatmicrosof…
zhangyiatmicrosoft Mar 4, 2024
762dc0c
Merge branch 'main' into fix-plugin-msg
zhangyiatmicrosoft Mar 5, 2024
89c12b9
PR
zhangyiatmicrosoft Mar 6, 2024
b039280
replace exception with console.error
zhangyiatmicrosoft Mar 6, 2024
1cf03dd
update comment to be more accurate
zhangyiatmicrosoft Mar 6, 2024
7e15785
Merge branch 'main' into fix-plugin-msg
zhangyiatmicrosoft Mar 6, 2024
44d2b84
do not download from main thread
zhangyiatmicrosoft Mar 7, 2024
f725ac6
remove extra try/catch
zhangyiatmicrosoft Mar 7, 2024
f46db6c
remove extra throw
zhangyiatmicrosoft Mar 7, 2024
c15def2
remove extra import
zhangyiatmicrosoft Mar 7, 2024
0ca962c
exception handling
zhangyiatmicrosoft Mar 11, 2024
191192c
correct version
zhangyiatmicrosoft Mar 11, 2024
07fcc22
Merge branch 'maplibre:main' into fix-plugin-msg
zhangyiatmicrosoft Mar 12, 2024
3ad1e71
all UT
zhangyiatmicrosoft Mar 12, 2024
403d33f
UT
zhangyiatmicrosoft Mar 13, 2024
e49229d
add tests (#7)
zhangyiatmicrosoft Mar 13, 2024
0b90b80
Merge branch 'fix-plugin-msg' of https://github.com/zhangyiatmicrosof…
zhangyiatmicrosoft Mar 13, 2024
560a66c
remove extra import
zhangyiatmicrosoft Mar 13, 2024
90227e4
clean up comments
zhangyiatmicrosoft Mar 13, 2024
91e82ed
test update
zhangyiatmicrosoft Mar 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/source/rtl_text_plugin_main_thread.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,23 @@ class RTLMainThreadPlugin extends Evented {
dispatcher: Dispatcher = getGlobalDispatcher();
queue: PluginState[] = [];

async _sendPluginStateToWorker() {
private async _sendPluginStateToWorker() {
await this.dispatcher.broadcast('syncRTLPluginState', {pluginStatus: this.pluginStatus, pluginURL: this.pluginURL});
this.fire(new Event('pluginStateChange', {pluginStatus: this.pluginStatus, pluginURL: this.pluginURL}));
this.dispatcher.broadcast('syncRTLPluginState', {pluginStatus: this.pluginStatus, pluginURL: this.pluginURL}).then(
(broadCastResults: boolean[]) => {
// should fire pluginStateChange event only if at least one of the receiver actually changed plugin status
if (broadCastResults) {
for (const result of broadCastResults) {
if (result) {
this.fire(new Event('pluginStateChange',
{
pluginStatus: this.pluginStatus,
pluginURL: this.pluginURL
}));
}
}
}
});
}

getRTLTextPluginStatus() {
Expand Down
7 changes: 6 additions & 1 deletion src/source/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,12 @@ export default class Worker {
private async _syncRTLPluginState(map: string, state: PluginState): Promise<boolean> {
rtlWorkerPlugin.setState(state);
const pluginURL = rtlWorkerPlugin.getPluginURL();
if (state.pluginStatus === 'loaded' && !rtlWorkerPlugin.isParsed() && pluginURL != null) {

const isLoaded =
state.pluginStatus === 'loaded' || // Main Thread: loaded if the completion callback returned successfully
rtlWorkerPlugin.applyArabicShaping != null; // Web-worker: loaded if the plugin functions have been compiled
HarelM marked this conversation as resolved.
Show resolved Hide resolved

if (isLoaded && !rtlWorkerPlugin.isParsed() && pluginURL != null) {
this.self.importScripts(pluginURL);
const complete = rtlWorkerPlugin.isParsed();
if (complete) {
Expand Down
Loading