-
Notifications
You must be signed in to change notification settings - Fork 54
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
Kb 48270 #990
base: master
Are you sure you want to change the base?
Kb 48270 #990
Conversation
feature: load formula asynchronous feat(viewer): add observer in order optimize performance feat: viewer improvement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some explanation
}; | ||
|
||
window.viewer.properties.config = config; | ||
|
||
document.getElementsByTagName("main")[0].innerHTML = document.getElementById("content").value; | ||
window.com.wiris.js.JsPluginViewer.parseElement(document.getElementsByTagName("main")[0]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It has been removed because we no longer need "Render under request."
@@ -48,6 +48,41 @@ function decodeSafeMathML(root: HTMLElement) { | |||
} | |||
} | |||
|
|||
export async function renderAMathML(properties: Properties, mathElement: MathMLElement): Promise<void> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to delete the renderMathML
function, but it seems to have a lot of implications and requires many document modifications. However, it appears worth discussing its feasibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like so too. I would even consider this part of the development of the task, since the renderMathML
is used for the retro-compatibility methods, which could benefit from the new performance improvements.
It would require a part of investigation and maybe adapt the current methods so that renderMathML
can be properly replaced.
packages/viewer/docs/spec.md
Outdated
@@ -112,6 +112,9 @@ The following table contains a specification of each of the properties. | |||
| lang | The language for the alt text. | Frontend | | en | | |||
| dpi | Resolution in dots per inch of the generated image. This feature scales the formula with a factor of dpi/96. | Frontend | Positive integer | 96 | | |||
| zoom | The scale of the generated image. | Frontend | Positive floating point number | 1 | | |||
| vieweroffset | Number of pixels to render in advance. | Frontend | Positive floating point number | 200 | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm missing maybe some information on what would that parameter be of use, because if I'm using the viewer for the first time, with that information I would not understand.
Maybe add something like "We render only the formulas on screen. This parameter defines the ..."
packages/viewer/docs/spec.md
Outdated
@@ -112,6 +112,9 @@ The following table contains a specification of each of the properties. | |||
| lang | The language for the alt text. | Frontend | | en | | |||
| dpi | Resolution in dots per inch of the generated image. This feature scales the formula with a factor of dpi/96. | Frontend | Positive integer | 96 | | |||
| zoom | The scale of the generated image. | Frontend | Positive floating point number | 1 | | |||
| vieweroffset | Number of pixels to render in advance. | Frontend | Positive floating point number | 200 | | |||
| simultaneousmml | Mmax number of simultaneous MathML rendering petition can make at the same time. | Frontend | Positive floating point number | 50 | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| simultaneousmml | Mmax number of simultaneous MathML rendering petition can make at the same time. | Frontend | Positive floating point number | 50 | | |
| simultaneousmml | Max number of possible simultaneous MathML rendering petitions at the same time. | Frontend | Positive floating point number | 50 | |
packages/viewer/docs/spec.md
Outdated
@@ -112,6 +112,9 @@ The following table contains a specification of each of the properties. | |||
| lang | The language for the alt text. | Frontend | | en | | |||
| dpi | Resolution in dots per inch of the generated image. This feature scales the formula with a factor of dpi/96. | Frontend | Positive integer | 96 | | |||
| zoom | The scale of the generated image. | Frontend | Positive floating point number | 1 | | |||
| vieweroffset | Number of pixels to render in advance. | Frontend | Positive floating point number | 200 | | |||
| simultaneousmml | Mmax number of simultaneous MathML rendering petition can make at the same time. | Frontend | Positive floating point number | 50 | | |||
| simultaneouslatex | max number of simultaneous LaTeX rendering petition can make at the same time. | Frontend | Positive floating point number | 50 | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| simultaneouslatex | max number of simultaneous LaTeX rendering petition can make at the same time. | Frontend | Positive floating point number | 50 | | |
| simultaneouslatex | Max number of possible simultaneous LaTeX rendering petitions at the same time. | Frontend | Positive floating point number | 50 | |
// Interaction Observer | ||
const mathobserver = new IntersectionObserver(async (entries, observer) => { | ||
|
||
let latexPromises = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that you are using the simultaneousmml
but I fail to find the place where the simultaneouslatex
is being used. It seems then that the parameter is not providing any value to the viewer at this point. Is this intentional, or am I failing to see something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here!
In Latex.ts, line 21:
const maxLatexPetition = properties.simultaneousmml;
Maybe maxLatexPetition should be equal to properties.simultaneouslatex?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My mistake! It should be const maxLatexPetition = properties.simultaneouslatex;
FIxed, thank you both!
@@ -48,6 +48,41 @@ function decodeSafeMathML(root: HTMLElement) { | |||
} | |||
} | |||
|
|||
export async function renderAMathML(properties: Properties, mathElement: MathMLElement): Promise<void> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like so too. I would even consider this part of the development of the task, since the renderMathML
is used for the retro-compatibility methods, which could benefit from the new performance improvements.
It would require a part of investigation and maybe adapt the current methods so that renderMathML
can be properly replaced.
packages/viewer/src/app.ts
Outdated
|
||
const allElements = document.querySelectorAll('*'); | ||
window.addEventListener("load", function () { | ||
let counter = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this counter used for something?
Looks like a development tool XD
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deleted! Thank you!
for (const entry of entries) { | ||
|
||
if (entry.isIntersecting && entry.target instanceof MathMLElement && entry.target.matches('math')) { | ||
const promise = renderAMathML(properties, entry.target); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I am missing something, but:
Why the renderAMathMl method does not implement the petition guard and renderLatex does?
Could be possible to implement the guard logic in the same way for both methods? For me is kind of confusing that one does the guard mechanism and the other doesn't.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we talked in private, renderAMathMl and renderLatex have some different behavior, that's why they don't share the same guard mechanism
Hey, remember to add the decode so this work ! 😊«math xmlns=¨http://www.w3.org/1998/Math/MathML¨»«mfrac»«mrow»«mi»r«/mi»«mi»e«/mi»«/mrow»«mi»w«/mi»«/mfrac»«mi»r«/mi»«/math» |
Description
Optimized the performance of the viewer by implementing the following:
Steps to reproduce
yarn && nx build viewer && nx start html-viewer
or in kitchensimultaneousmml
simultaneouslatex
vieweroffset
#48270