Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic How to imporve performance? (Read 1544 times)
Kannan Thirumal
Senior Member
****
Offline


I Love Mind Fusion Diagram
:-)

Posts: 284
Location: Bangalore, India
Joined: Jan 18th, 2019
How to imporve performance?
May 17th, 2021 at 7:22am
Print Post  
Hi,

     requestAnimationFrame calls diagram’s method “repaint” continually which impacts the load performance a lot. Could you please provide a solution to improve the load performance or to disable calling repaint from requestAnimationFrame?

Regards,
Kannan
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3435
Joined: Oct 19th, 2005
Re: How to imporve performance?
Reply #1 - May 17th, 2021 at 8:11am
Print Post  
Hi,

Set a breakpoint in diagram's invalidate method to see what triggers repainting for you. Usually it should be a single repaint for a set of diagram changes. E.g. if you add this code to AnchorPoints example, it will print 'repainting' only when you point a node with the mouse to show the auto-anchor marks, or click to show selection handles -

Code
Select All
$(document).ready(function (sender, args)
{
	var originalRepaint = Diagram.prototype.repaint;
	Diagram.prototype.repaint = function()
	{
		console.log("repainting");
		originalRepaint.apply(this);
	}
	var originalInvalidate = Diagram.prototype.invalidate;
	Diagram.prototype.invalidate = function(rect, force)
	{
		console.log("invalidating");
		originalInvalidate.apply(this, [rect, force]);
	}

    // create a Diagram component that wraps the "diagram" canvas
    //diagram = MindFusion.AbstractionLayer.createControl(Diagram, null, null, null, $("#diagram")[0]);
    diagram = MindFusion.Diagramming.Diagram.create(document.getElementById("diagram"));
 



Repaint sequence looks like item.setProperty -> item.invalidate -> diagram.invalidate -> window.requestAnimationFrame -> diagram.repaint. requestAnimationFrame makes multiple invalidate calls compress into a single repaint. So if you are seeing repaint calls without user interactions, make sure you aren't changing property values from custom-drawing code or from timers.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint