Number of DOM nodes/events calculated inconsistent with numbers in Chrome dev tools - dom

I noticed that on my site the Google Chrome developer tools “Performance Monitor” shows different numbers than those determined via getEventListeners() and document.querySelectorAll('*').
As you can see in the screenshot below, the number of events calculated in the console is significantly higher than the one stated in the Chrome dev tools while the number of DOM Nodes is significantly lower.
Any idea how this can be explained?
function countDomEventListeners (elements) {
return Array.from(elements).reduce((count, node) => {
const listeners = getEventListeners(node)
for (var eventName in listeners) {
count += listeners[eventName].length
}
return count
}, 0)
}
elements = document.querySelectorAll('*')
console.log('DOM Nodes:', elements.length)
console.log('DOM event listeners:', countDomEventListeners(elements))

I built a little example with around 1020 DOM nodes and 1000 events on the <li/> elements. Each click removes its own event listener and after 10 clicks, all event listeners are removed.
The Google Chrome performance monitor does indeed behave in unexpected ways. It sometimes shows around 35, 50, 150, or more events and ~2000 or ~4000 DOM nodes while the countDomEventListeners() function in the original question always calculates the expected numbers (~1020 DOM nodes and exactly 1000 events).
When using the "Elements" tab in the Google Chrome dev tools and hovering over DOM nodes there, both the DOM nodes and events counts in the performance monitor do heavily fluctuate and go up, which brings me to the conclusion that the dev tools themselves leak into the performance monitor statistics.
I've reported the problem here.

Related

How to detect if InputSystem.EnhancedTouch.Finger is over UI Toolkit Element?

I'm using InputSystem.EnhancedTouch for my game and I have a few buttons that are available through UI Elements. When I click on the UI Elements buttons it activates the InputSystem thus creating a bad experience. I want to filter out all the InputSystem.EnhancedTouch events that come through UI.
TL;DR - I want UI Elements to block InputSystem.EnhancedTouch events from triggering
I have found quite some resources but nothing really works. Unity and some other people say to use EventSystem.current.IsPointerOverGameObject but it doesn't work and throws the following warning(I think this is meant to work with normal input only, not enhanced one)
I have tried a few other solutions such as UIDocument.rootVisualElement.panel.Pick or EventSystem.current.RaycastAll but nothing seems to work, or return any consistent data that can be used.
InputSystem.EnhancedTouch binding
private void Awake()
{
EnhancedTouchSupport.Enable();
Touch.onFingerDown += OnFingerDown;
Touch.onFingerMove += OnFingerMove;
Touch.onFingerUp += OnFingerUp;
}

How do I run my syncronus search function wihout blocking my flutter app?

I am building a flutter application which searches a low level communication bus for devices and displays them in a table. Communication over the low level bus is slow, default speed is 4800 bits/s.
I want to run my search in the background so that the application is not halted for 10+ seconds every time the user performs a search. I also want to add the results to the table as the search function finds them (using the onFound argument to search).
SearchBar(
onSearch: (selection, parametersToDisplay) {
clearSearchResults();
communcationBus.search(selection, parametersToDisplay, onFound: (device) {addToSearchResults(device)})
},
onUpdateSearch: (display) {}, // TODO
)
You can achieve this using Isolates.
For a short conceptual intro, take a look at this Medium post by a Dart documentation writer.
The FlutterIsolate package (pub link) can help you to abstract out some of the complicated things.
You can use it to spawn a new isolate, which performs your slow operations. You can then store it in your app or use the SendPort/ReceivePort to send the result data to your main isolate.

What does "requestTime" number mean in Chrome DevTools?

According Chrome DevTools Protocol viewer the value of requestTime is a baseline in seconds. To understand it I took this value from few web pages and for all of them the value of requestTime was unexpectedly large. For example one of them was 13133423 seconds. Does anyone know why the value of requestTime is too large? And what requestTime value mean?
Quoting the source code:
We want to present a unified timeline to Javascript. Using walltime is
problematic, because the clock may skew while resources load. To prevent
that skew, we record a single reference walltime when root document
navigation begins.
All other times are recorded using
monotonicallyIncreasingTime().
When a time needs to be presented to
Javascript, we build a pseudo-walltime using the following equation
(m_requestTime as example): pseudo time = document wall reference + (m_requestTime - document monotonic reference)
All values from monotonicallyIncreasingTime(), in base::TimeTicks.
More info on monotonicallyIncreasingTime: https://stackoverflow.com/a/39634132

Switch monitor position in Weston

Is it possible to indicate monitor position in Weston/Wayland?
I have two monitors and been testing the Weston compositor, but I have been unable to indicate which monitor should be the main one (or which one should show the "left part" of the screen).
Checking the weston.ini docs (http://manpages.ubuntu.com/manpages/xenial/en/man5/weston.ini.5.html) I found info about setting resolution, scaling and transform/rotation, but nothing about the position of the monitors.
I have been interested into the same some weeks ago. I send the question to the wayland IRC channel.
You can have a look at:
https://people.freedesktop.org/~cbrill/dri-log/index.php?channel=wayland&highlight_names=&date=2017-12-19
https://people.freedesktop.org/~cbrill/dri-log/index.php?channel=wayland&highlight_names=&date=2017-12-20
Here is the relevant part:
22:31 maggu2810: Is there any change to change the display / output position in weston? I am using three outputs but don't know how to configure which one if left / right of the other one.
22:33 maggu2810: ... chance to change ...
22:35 maggu2810: the output sections in weston.ini currently contains the name, the mode and the scale. I didn't find any "position" option or anything that looks like an option to modify the "order" of the displays.
07:07 pq: maggu2810, yes, not implemented yet, there were indeed some WIP patches in 2016
Perhaps you will be able to post a feature request in their mailing list. I don't think they will look for feature requests on SO ;)

sencha touch :: how to handle long lists on iOS

in my sencha touch app I need to display a list of over 600 entries of objects per selected customer.
imagine one store holds some customers, displayed in a list. each of them has some "has-many"-related sub-stores, one holding about 600 objects (with urls, title, description...). these sub-info has to be listed when you select one customer from the first list.
the problem is on iOS you have to wait some seconds before the list is shown and it is very slow to scroll/use. it seems that it slows down the whole app.
are there any other options to display long lists, maybe like pagination ore something...
thnx!
edit: I found this article and will test these thoughts soon: Link
edit2: here we go: https://github.com/Lioarlan/UxBufList-Sench-Touch-Extension
You can paginate your list by adding a pageSize param to your store and the listpaging plugin to your list. By setting the autoPaging option, you can control whether the data is loaded automatically or on user click. Below is an example:
// store
Ext.regStore('BarginsStore', {
model: 'BarginModel',
autoLoad: true,
pageSize: 6,
clearOnPageLoad: false,
sorters: 'category',
getGroupString: function(record) {
return record.get('category');
}
});
// list
this.list = new Ext.List({
store: 'BarginsStore',
plugins: [{
ptype: 'listpaging',
autoPaging: true
}],
singleSelection: true,
emptyText: '<p class="no-bargins">No bargins found matching this criteria.</p>',
itemTpl: '<div class="bargin-record">{name}</div>'
});
are there any other options to display long lists, maybe like pagination ore something...
Pagination. Smartphones have far more limited CPU and RAM resources than a desktop PC. A six hundred row table with several elements is not going to display well on the devices on the market now. Hell, it'll probably slow down desktop browsers. Paginate it.