WPF Performance - Finding Source of Layout Pass Invocation -


is there way figure out why/what invoked wpf layout pass control?

i tracking amount of arrange overrides being called our main user control:

public partial class myview {     private ulong _arrangecount;     protected override size arrangeoverride(size arrangebounds)     {         debug.writeline($"ttv - arrangeoverride - {_arrangecount++}");         return base.arrangeoverride(arrangebounds);     } } 

the counts of loading view 40! complex ui (data grids nested, 100's of cells , custom templates columns,cells,rows) taking seconds! (a large portion of time spent in measure/arrange)

is there way find out source of each pass?

at moment removing things user control , trying figure out causing bunch of these.

i did notice there lot of things stored in effective values, because of bindings in styles/templates inside main control resource dictionaries?

would update effective values (even though of them not affect parent control, cause measure/arrange invoked?)

i have managed cache measure size follows seems have helped on measure side, arrange, cannot same not arrange correctly, after content has been bound!

    private size _lastmeasureconstraint;      private ulong _measurecount;     protected override size measureoverride(size constraint)     {         if (_lastmeasureconstraint == constraint)             return constraint;          debug.writeline($"ttv - measureoverride - {_measurecount++}");         _lastmeasureconstraint = constraint;         return base.measureoverride(constraint);     } 

stack of of measure/arrange overrides:

 @ system.environment.getstacktrace(exception e, boolean needfileinfo)    @ system.environment.get_stacktrace()     // hook in check how many arrange overrides happen    @ myassembly.myusercontrol.arrangeoverride(size arrangebounds) in myusercontrol.cs:line 103    @ system.windows.frameworkelement.arrangecore(rect finalrect)    @ system.windows.uielement.arrange(rect finalrect)    @ system.windows.contextlayoutmanager.updatelayout()    @ system.windows.contextlayoutmanager.updatelayoutcallback(object arg)    @ system.windows.media.mediacontext.fireinvokeonrendercallbacks()    @ system.windows.media.mediacontext.rendermessagehandlercore(object resizedcompositiontarget)     // makes me think animation? wrong though!    @ system.windows.media.mediacontext.animatedrendermessagehandler(object resizedcompositiontarget)    @ system.windows.threading.exceptionwrapper.internalrealcall(delegate callback, object args, int32 numargs)    @ system.windows.threading.exceptionwrapper.trycatchwhen(object source, delegate callback, object args, int32 numargs, delegate catchhandler)    @ system.windows.threading.dispatcheroperation.invokeimpl()    @ system.threading.executioncontext.runinternal(executioncontext executioncontext, contextcallback callback, object state, boolean preservesyncctx)    @ system.threading.executioncontext.run(executioncontext executioncontext, contextcallback callback, object state, boolean preservesyncctx)    @ system.threading.executioncontext.run(executioncontext executioncontext, contextcallback callback, object state)    @ ms.internal.culturepreservingexecutioncontext.run(culturepreservingexecutioncontext executioncontext, contextcallback callback, object state)    @ system.windows.threading.dispatcheroperation.invoke()    @ system.windows.threading.dispatcher.processqueue()    @ system.windows.threading.dispatcher.wndprochook(intptr hwnd, int32 msg, intptr wparam, intptr lparam, boolean& handled)    @ ms.win32.hwndwrapper.wndproc(intptr hwnd, int32 msg, intptr wparam, intptr lparam, boolean& handled)    @ ms.win32.hwndsubclass.dispatchercallbackoperation(object o)    @ system.windows.threading.exceptionwrapper.internalrealcall(delegate callback, object args, int32 numargs)    @ system.windows.threading.exceptionwrapper.trycatchwhen(object source, delegate callback, object args, int32 numargs, delegate catchhandler)    @ system.windows.threading.dispatcher.legacyinvokeimpl(dispatcherpriority priority, timespan timeout, delegate method, object args, int32 numargs)    @ ms.win32.hwndsubclass.subclasswndproc(intptr hwnd, int32 msg, intptr wparam, intptr lparam)    @ ms.win32.unsafenativemethods.dispatchmessage(msg& msg)    @ ms.win32.unsafenativemethods.dispatchmessage(msg& msg)    @ system.windows.threading.dispatcher.pushframeimpl(dispatcherframe frame)    @ system.windows.threading.dispatcheroperation.wait(timespan timeout)    @ system.windows.threading.dispatcher.invokeimpl(dispatcheroperation operation, cancellationtoken cancellationtoken, timespan timeout)    @ system.windows.threading.dispatcher.invoke(action callback, dispatcherpriority priority, cancellationtoken cancellationtoken, timespan timeout)    @ system.windows.threading.dispatcher.invoke(action callback, dispatcherpriority priority)     // dispatcher wrapper exposes async/await methods. await state machine    @ myassembly.services.dispatcher.wpfdispatcher.<invoke>d__5.movenext() in wpfdispatcher.cs:line 37    @ system.runtime.compilerservices.asynctaskmethodbuilder.start[tstatemachine](tstatemachine& statemachine)    @ myassembly.services.dispatcher.wpfdispatcher.invoke(dispatcherpriority priority, action action)    @ myassembly.services.dispatcher.dispatch.invoke(dispatcherpriority priority, action action) in dispatch.cs:line 176    @ myassembly.services.dispatcher.dispatch.p3_contextidle(action action) in dispatch.cs:line 76     // top level await, async/await state machine starts    @ myassembly.myusercontrol.<>c__displayclass348_0.<<mymethod>b__0>d.movenext() in myusercontrol.cs:line 3449    @ system.threading.executioncontext.runinternal(executioncontext executioncontext, contextcallback callback, object state, boolean preservesyncctx)    @ system.threading.executioncontext.run(executioncontext executioncontext, contextcallback callback, object state, boolean preservesyncctx)    @ system.runtime.compilerservices.asyncmethodbuildercore.movenextrunner.run()    @ system.windows.threading.exceptionwrapper.internalrealcall(delegate callback, object args, int32 numargs)    @ system.windows.threading.exceptionwrapper.trycatchwhen(object source, delegate callback, object args, int32 numargs, delegate catchhandler)    @ system.windows.threading.dispatcheroperation.invokeimpl()    @ system.threading.executioncontext.runinternal(executioncontext executioncontext, contextcallback callback, object state, boolean preservesyncctx)    @ system.threading.executioncontext.run(executioncontext executioncontext, contextcallback callback, object state, boolean preservesyncctx)    @ system.threading.executioncontext.run(executioncontext executioncontext, contextcallback callback, object state)    @ ms.internal.culturepreservingexecutioncontext.run(culturepreservingexecutioncontext executioncontext, contextcallback callback, object state)    @ system.windows.threading.dispatcheroperation.invoke()    @ system.windows.threading.dispatcher.processqueue()    @ system.windows.threading.dispatcher.wndprochook(intptr hwnd, int32 msg, intptr wparam, intptr lparam, boolean& handled)    @ ms.win32.hwndwrapper.wndproc(intptr hwnd, int32 msg, intptr wparam, intptr lparam, boolean& handled)    @ ms.win32.hwndsubclass.dispatchercallbackoperation(object o)    @ system.windows.threading.exceptionwrapper.internalrealcall(delegate callback, object args, int32 numargs)    @ system.windows.threading.exceptionwrapper.trycatchwhen(object source, delegate callback, object args, int32 numargs, delegate catchhandler)    @ system.windows.threading.dispatcher.legacyinvokeimpl(dispatcherpriority priority, timespan timeout, delegate method, object args, int32 numargs)    @ ms.win32.hwndsubclass.subclasswndproc(intptr hwnd, int32 msg, intptr wparam, intptr lparam)    @ ms.win32.unsafenativemethods.dispatchmessage(msg& msg)    @ ms.win32.unsafenativemethods.dispatchmessage(msg& msg)    @ system.windows.threading.dispatcher.pushframeimpl(dispatcherframe frame)    @ system.windows.application.rundispatcher(object ignore)    @ system.windows.application.runinternal(window window)    @  myassembly.app.main() 


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -