NaN bug in console view

Current Development version likely to have breaking changes
Post Reply
PencilGeek
Posts: 13
Joined: Wed May 28, 2025 2:45 pm

NaN bug in console view

Post by PencilGeek »

Here's an easy repro of a NaN bug. Possibly a divide-by-zero, or using a floating point number from uninitialized memory location, who knows. This is my first time reporting a bug, so if this is the wrong location, please let me know.

Version: ToT: 1.37.66.

Steps:
Console -> Click any camera view
Click <View All>
Scroll to bottom
See NaN at bottom-left of row count.
User avatar
iconnor
Posts: 3391
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: NaN bug in console view

Post by iconnor »

Thanks for the report... but I'm not able to reproduce it yet.

I assume when you said to click on View All you meant "All Events" which takes us to the events view... which SHOULD be the same as click on the events count in the ALL column for that camera. Can you try that and see if it does the same thing?

Are there rows returned?
PencilGeek
Posts: 13
Joined: Wed May 28, 2025 2:45 pm

Re: NaN bug in console view

Post by PencilGeek »

iconnor wrote: Sun Jun 15, 2025 3:02 pm Thanks for the report... but I'm not able to reproduce it yet.

I assume when you said to click on View All you meant "All Events" which takes us to the events view... which SHOULD be the same as click on the events count in the ALL column for that camera. Can you try that and see if it does the same thing?

Are there rows returned?
Yes, I meant "All Events." When I click on the event counts, I see the same thing. Bottom left of the screen says:
Showing NaN to NaN of 175 rows [NaN] rows per page

It's not limited to a specific camera, does it on all of them. Then in the logs, I see this:
6/16/25, 1:13:04 PM PDT web_php 57393 ERR Invalid value for limit: NaN /usr/share/zoneminder/www/ajax/events.php 92
6/16/25, 1:13:04 PM PDT web_php 57393 ERR Invalid value for offset: NaN /usr/share/zoneminder/www/ajax/events.php 81
6/16/25, 1:13:04 PM PDT web_php 33534 ERR Invalid value for limit: NaN /usr/share/zoneminder/www/ajax/events.php 92
6/16/25, 1:13:04 PM PDT web_php 33534 ERR Invalid value for offset: NaN /usr/share/zoneminder/www/ajax/events.php 81
6/16/25, 1:13:04 PM PDT web_php 57687 ERR Invalid value for limit: NaN /usr/share/zoneminder/www/ajax/events.php 92
6/16/25, 1:13:04 PM PDT web_php 57687 ERR Invalid value for offset: NaN /usr/share/zoneminder/www/ajax/events.php 81
User avatar
iconnor
Posts: 3391
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: NaN bug in console view

Post by iconnor »

Is there anything in the logs before that? maybe in /var/log/apache2/error.log ?
PencilGeek
Posts: 13
Joined: Wed May 28, 2025 2:45 pm

Re: NaN bug in console view

Post by PencilGeek »

iconnor wrote: Mon Jun 16, 2025 9:36 pm Is there anything in the logs before that? maybe in /var/log/apache2/error.log ?
Nothing in apache2/error.log for the past few days.

I grepped for the NaN, and the only logs I found were the ones posted above: zm/web_php.log.

So then, I grepped for that timestamp, and the previous 5-seconds, and also only found the same log entries.
User avatar
iconnor
Posts: 3391
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: NaN bug in console view

Post by iconnor »

Yeha it won't be NaN, the NaN will be because we returned 0 results or nothing at all, or something like that. Can you turn on debug logging Options->Logging->Debug

It should put a lot of verbose logs into /var/log/zm/web_php.log which should include the results of the events list query. Which should shed some light.
PencilGeek
Posts: 13
Joined: Wed May 28, 2025 2:45 pm

Re: NaN bug in console view

Post by PencilGeek »

iconnor wrote: Mon Jun 16, 2025 10:03 pm Yeha it won't be NaN, the NaN will be because we returned 0 results or nothing at all, or something like that. Can you turn on debug logging Options->Logging->Debug

It should put a lot of verbose logs into /var/log/zm/web_php.log which should include the results of the events list query. Which should shed some light.
Forgive me for not remembering how to attach files to phpBB. I searched the log for the NaN, then went backwards until I found the most recent SQL query. I can see that the NaN appears in a results array before any SQL query in the log. I figure that's probably what you want to see. Let me know if you want more. There's a bunch of odd ffmpeg spew in there as well, complaining that it can't write to a file. Not sure why, as the path on that does exist, and the owner/group permissions are set to www-data:www-data. Here's a section of the log that might be most relevant.

cat /var/log/zm/web_php.log.debug
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A
displaymatrix: rotation of -0.00 degrees
frame= 1 fps=0.0 q=8.6 Lsize=N/A time=00:00:00.03 bitrate=N/A speed=0.0348x
video:198kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown] at /usr/share/zoneminder/www/views/image.php line 342
6/16/25, 3:09:24 PM PDT.584038 web_php[55812].DBG [98.188.57.164] [Doing a scaled image: scale(0) width(48) height(85)] at /usr/share/zoneminder/www/views/image.php line 499
6/16/25, 3:09:24 PM PDT.584091 web_php[55812].DBG [98.188.57.164] [Cached scaled image does not exist at /var/cache/zoneminder/events/1/2025-06-15/3432/snapshot-48x85.jpg. Creating it] at /usr/share/zoneminder/www/views/image.php line 527
6/16/25, 3:09:24 PM PDT.613939 web_php[55812].DBG [98.188.57.164] [Have image scaling to 48 x 85] at /usr/share/zoneminder/www/views/image.php line 541
6/16/25, 3:09:24 PM PDT.621953 web_php[49602].DBG [98.188.57.164] [Array
(
[view] => request
[request] => events
[task] => query
[filter] => Array
(
[Query] => Array
(
[terms] => Array
(
[0] => Array
(
[cnj] => and
[attr] => Monitor
[op] => =
[val] => Array
(
[0] => 1
)

)

[1] => Array
(
[cnj] => and
[attr] => StartDateTime
[op] => >=
[val] =>
)

[2] => Array
(
[cnj] => and
[attr] => EndDateTime
[op] => <=
[val] =>
)

[3] => Array
(
[cnj] => and
[attr] => Notes
[op] => LIKE
[val] =>
)

[4] => Array
(
[cnj] => and
[attr] => Tags
[op] => =
[val] =>
)

[5] => Array
(
[cnj] => and
[attr] => Archived
[op] => =
[val] =>
)

)

[sort_asc] => 1
[sort_field] => StartDateTime
)

)

[__csrf_magic] => key:8e04f41d7289b3befa405e2d6e5c97aa1e6abb7d,1750111764
[search] =>
[sort] => StartDateTime
[order] => asc
[offset] => NaN
[limit] => NaN
)] at /usr/share/zoneminder/www/index.php line 33
6/16/25, 3:09:24 PM PDT.623403 web_php[49602].DBG [98.188.57.164] [View: request Request: events Action: User: admin] at /usr/share/zoneminder/www/index.php line 187
6/16/25, 3:09:24 PM PDT.624707 web_php[49602].ERR [98.188.57.164] [Invalid value for offset: NaN] at /usr/share/zoneminder/www/ajax/events.php line 81
6/16/25, 3:09:24 PM PDT.625537 web_php[49602].ERR [98.188.57.164] [Invalid value for limit: NaN] at /usr/share/zoneminder/www/ajax/events.php line 92
6/16/25, 3:09:24 PM PDT.626941 web_php[49602].DBG [98.188.57.164] [Calling the following sql query: SELECT
E.*,
UNIX_TIMESTAMP(E.StartDateTime) AS StartTimeSecs,
CASE WHEN E.EndDateTime IS NULL THEN (SELECT NOW()) ELSE E.EndDateTime END AS EndDateTime,
CASE WHEN E.EndDateTime IS NULL THEN (SELECT UNIX_TIMESTAMP(NOW())) ELSE UNIX_TIMESTAMP(EndDateTime) END AS EndTimeSecs,
M.Name AS Monitor,
GROUP_CONCAT(T.Name SEPARATOR ", ") AS Tags FROM `Events` AS E
INNER JOIN Monitors AS M ON E.MonitorId = M.Id
LEFT JOIN Events_Tags AS ET ON E.Id = ET.EventId
LEFT JOIN Tags AS T ON T.Id = ET.TagId
WHERE ( E.MonitorId = '1'
)
GROUP BY E.Id, Monitor
ORDER BY E.StartDateTime ASC] at /usr/share/zoneminder/www/ajax/events.php line 242
6/16/25, 3:09:24 PM PDT.630073 web_php[49602].DBG [98.188.57.164] [Have 194 events matching base filter.] at /usr/share/zoneminder/www/ajax/events.php line 266
6/16/25, 3:09:24 PM PDT.634162 web_php[55812].DBG [98.188.57.164] [Array
(
[view] => request
[request] => events
[task] => query
[filter] => Array
(
[Query] => Array
(
[terms] => Array
(
[0] => Array
(
[cnj] => and
[attr] => Monitor
[op] => =
[val] => Array
(
[0] => 1
)

)

[1] => Array
(
[cnj] => and
[attr] => StartDateTime
[op] => >=
[val] =>
)

[2] => Array
(
[cnj] => and
[attr] => EndDateTime
[op] => <=
[val] =>
)

[3] => Array
(
[cnj] => and
[attr] => Notes
[op] => LIKE
[val] =>
)

[4] => Array
(
[cnj] => and
[attr] => Tags
[op] => =
[val] =>
)

[5] => Array
(
[cnj] => and
[attr] => Archived
[op] => =
[val] =>
)

)

[sort_asc] => 1
[sort_field] => StartDateTime
)

)

[__csrf_magic] => key:8e04f41d7289b3befa405e2d6e5c97aa1e6abb7d,1750111764
[search] =>
[sort] => StartDateTime
[order] => asc
[offset] => NaN
[limit] => NaN
)] at /usr/share/zoneminder/www/index.php line 33
6/16/25, 3:09:24 PM PDT.635539 web_php[55812].DBG [98.188.57.164] [View: request Request: events Action: User: admin] at /usr/share/zoneminder/www/index.php line 187
6/16/25, 3:09:24 PM PDT.636743 web_php[55812].ERR [98.188.57.164] [Invalid value for offset: NaN] at /usr/share/zoneminder/www/ajax/events.php line 81
6/16/25, 3:09:24 PM PDT.637615 web_php[55812].ERR [98.188.57.164] [Invalid value for limit: NaN] at /usr/share/zoneminder/www/ajax/events.php line 92
6/16/25, 3:09:24 PM PDT.639028 web_php[55812].DBG [98.188.57.164] [Calling the following sql query: SELECT
E.*,
UNIX_TIMESTAMP(E.StartDateTime) AS StartTimeSecs,
CASE WHEN E.EndDateTime IS NULL THEN (SELECT NOW()) ELSE E.EndDateTime END AS EndDateTime,
CASE WHEN E.EndDateTime IS NULL THEN (SELECT UNIX_TIMESTAMP(NOW())) ELSE UNIX_TIMESTAMP(EndDateTime) END AS EndTimeSecs,
M.Name AS Monitor,
GROUP_CONCAT(T.Name SEPARATOR ", ") AS Tags FROM `Events` AS E
INNER JOIN Monitors AS M ON E.MonitorId = M.Id
LEFT JOIN Events_Tags AS ET ON E.Id = ET.EventId
LEFT JOIN Tags AS T ON T.Id = ET.TagId
WHERE ( E.MonitorId = '1'
)
GROUP BY E.Id, Monitor
ORDER BY E.StartDateTime ASC] at /usr/share/zoneminder/www/ajax/events.php line 242
6/16/25, 3:09:24 PM PDT.642174 web_php[55812].DBG [98.188.57.164] [Have 194 events matching base filter.] at /usr/share/zoneminder/www/ajax/events.php line 266
6/16/25, 3:09:24 PM PDT.675026 web_php[60492].DBG [98.188.57.164] [Array
(
[view] => request
[request] => events
[task] => query
[filter] => Array
(
[Query] => Array
(
[terms] => Array
(
[0] => Array
(
[cnj] => and
[attr] => Monitor
[op] => =
[val] => Array
(
[0] => 1
)

)

[1] => Array
(
[cnj] => and
[attr] => StartDateTime
[op] => >=
[val] =>
)

[2] => Array
(
[cnj] => and
[attr] => EndDateTime
[op] => <=
[val] =>
)

[3] => Array
(
[cnj] => and
[attr] => Notes
[op] => LIKE
[val] =>
)

[4] => Array
(
[cnj] => and
[attr] => Tags
[op] => =
[val] =>
)

[5] => Array
(
[cnj] => and
[attr] => Archived
[op] => =
[val] =>
)

)

[sort_asc] => 1
[sort_field] => StartDateTime
)

)

[__csrf_magic] => key:8e04f41d7289b3befa405e2d6e5c97aa1e6abb7d,1750111764
[search] =>
[sort] => StartDateTime
[order] => asc
[offset] => NaN
[limit] => NaN
[undefined] =>
)] at /usr/share/zoneminder/www/index.php line 33
User avatar
iconnor
Posts: 3391
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: NaN bug in console view

Post by iconnor »

Latest build should get rid of Nan errors, hopefully allowing us to see the real problem.
PencilGeek
Posts: 13
Joined: Wed May 28, 2025 2:45 pm

Re: NaN bug in console view

Post by PencilGeek »

iconnor wrote: Fri Jun 20, 2025 11:35 am Latest build should get rid of Nan errors, hopefully allowing us to see the real problem.
That fixed the issue. When you want to "see the real problem" is there something else you want me to look at?
User avatar
iconnor
Posts: 3391
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: NaN bug in console view

Post by iconnor »

Well it has to be in the javascript... We need to look at what the results from the events load are, and why that is resulting in NaN. So if you look at the network tab of developer tools, and see the requests for the events list and see the results from that... maybe it will shed light. Otherwise, There may be errors in the console that might shed a clue.
PencilGeek
Posts: 13
Joined: Wed May 28, 2025 2:45 pm

Re: NaN bug in console view

Post by PencilGeek »

iconnor wrote: Sat Jun 21, 2025 6:28 pm Well it has to be in the javascript... We need to look at what the results from the events load are, and why that is resulting in NaN. So if you look at the network tab of developer tools, and see the requests for the events list and see the results from that... maybe it will shed light. Otherwise, There may be errors in the console that might shed a clue.
I'm finally back home. Being a ZM newbie, I'm not sure where to find the developer tools. I searched, and it looks like an additional download, but I haven't found it yet. Can you point me in the right direction, please?
User avatar
iconnor
Posts: 3391
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: NaN bug in console view

Post by iconnor »

Right click anywhere, click Inspect Element
PencilGeek
Posts: 13
Joined: Wed May 28, 2025 2:45 pm

Re: NaN bug in console view

Post by PencilGeek »

iconnor wrote: Thu Jun 26, 2025 1:47 pm Right click anywhere, click Inspect Element
In the network debug window, luxon-3.4.4.min.js appears to have many if/else statements that return either 0 or NaN. I didn't dig any further as I'm not sure this is where you wanted me to look.
Post Reply