Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Boxiang Sun
erp5
Commits
d5c716eb
Commit
d5c716eb
authored
Jun 10, 2019
by
Boxiang Sun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_notebook: Preload webassembly module on Chrome
parent
6c338d0c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
1 deletion
+47
-1
bt5/erp5_notebook/SkinTemplateItem/portal_skins/erp5_notebook/gadget_jsmd_eval.js.js
...ateItem/portal_skins/erp5_notebook/gadget_jsmd_eval.js.js
+47
-1
No files found.
bt5/erp5_notebook/SkinTemplateItem/portal_skins/erp5_notebook/gadget_jsmd_eval.js.js
View file @
d5c716eb
...
...
@@ -122,6 +122,50 @@
return
null
;
}
function
preloadWasm
()
{
// On Chrome, we have to instantiate wasm asynchronously. Since that
// can't be done synchronously within the call to dlopen, we instantiate
// every .so that comes our way up front, caching it in the
// `preloadedWasm` dictionary.
let
promise
=
new
Promise
((
resolve
)
=>
resolve
());
let
FS
=
pyodide
.
_module
.
FS
;
function
recurseDir
(
rootpath
)
{
let
dirs
;
var
entry
;
try
{
dirs
=
FS
.
readdir
(
rootpath
);
}
catch
{
return
;
}
for
(
entry
of
dirs
)
{
if
(
entry
.
startsWith
(
'
.
'
))
{
continue
;
}
const
path
=
rootpath
+
entry
;
if
(
entry
.
endsWith
(
'
.so
'
))
{
if
(
Module
[
'
preloadedWasm
'
][
path
]
===
undefined
)
{
promise
=
promise
.
then
(()
=>
Module
[
'
loadWebAssemblyModule
'
](
FS
.
readFile
(
path
),
{
loadAsync
:
true
}))
.
then
((
module
)
=>
{
Module
[
'
preloadedWasm
'
][
path
]
=
module
;
});
}
}
else
if
(
FS
.
isDir
(
FS
.
lookupPath
(
path
).
node
.
mode
))
{
recurseDir
(
path
+
'
/
'
);
}
}
}
recurseDir
(
'
/
'
);
return
promise
;
}
function
pyodideLoadPackage
(
names
)
{
// DFS to find all dependencies of the requested packages
var
queue
,
toLoad
,
package_uri
,
package_name
,
k
,
...
...
@@ -176,7 +220,9 @@
}
delete
pyodide
.
monitorRunDependencies
;
packageList
=
Array
.
from
(
Object
.
keys
(
toLoad
)).
join
(
'
,
'
);
resolve
(
"
Loaded
"
+
packageList
);
preloadWasm
().
then
(()
=>
{
resolve
(
`Loaded
${
packageList
}
`
)
});
}
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment