adrian

Tracy Debugger

Recommended Posts

Maybe it has been asked before, but when I have TracyDebugger disabled I get this error in the console of my developer tools:

Quote

Uncaught TypeError: Cannot read property 'DebugPanel' of undefined at window.onload

Could this be avoided by a try-catch block? It is not too important, but it would be great to not have this error.

And I cannot mention enough how great your module is. It helped me a lot of times. ;)

  • Like 1

Share this post


Link to post
Share on other sites

Hi @AndZyk - this was actually just fixed yesterday. Please update and let me know if you still have any problems.

  • Thanks 1

Share this post


Link to post
Share on other sites
17 hours ago, adrian said:

So for me, there really is no noticeable difference in load times. But we have seen discrepancies like this before. I remember when kongondo had really slow load times with the three objects in this panel, but it didn't affect you at all. Could you maybe determine which one of these three is causing the main slowdown? If it's "Config Data", then I would suggest just disabling that and using the Console panel and doing: d($config) whenever you want that info.

I had the time to do some testing, here it comes (my MAMP Pro):

  • API variables: 0.3ms
  • Core Classes: 0.4ms
  • Config Data: 270ms
  • Version List: 14ms
  • API variables + Core Classes + Admin Link + Doc Links: 0.9ms

The result of d($config) is:
Frontend:
syntax error, unexpected end of file
File: .../site/assets/cache/TracyDebugger/consoleCode.php:2
1: <?php if(!defined("PROCESSWIRE")) die("no direct access"); $page = $pages->get(1);
2: d($config)

Admin:
Same as above + 500: Internal Server Error: See the browser dev console for the actual error

Why? It used to work.

BTW, links in this Info panel do not not use _blank, why? I keep forgetting it which is kinda annoying after while. Is it just me? :) 

  • Like 1

Share this post


Link to post
Share on other sites
6 hours ago, szabesz said:

The result of d($config) is:
Frontend:
syntax error, unexpected end of file

You're missing the line ending semicolon ;)

d($config);

So it looks like "Config Data" is the culprit on your setup. I don't really know why it's so slow for you, and I don't really know how to improve it. Anyone else seeing that? If others chime in with a similar experience, I'll see what I can do, but I think for the moment it's probably best to just disable that and use d($config); as needed.

 

6 hours ago, szabesz said:

BTW, links in this Info panel do not not use _blank, why? I keep forgetting it which is kinda annoying after while. Is it just me?

I used to be all about _blank links, but these days I actually find them annoying because they give you no choice. A normal link lets you choose - I have three-finger / midd-click setup for open in new tab. If you are finding it that annoying though, I'd be happy to add a config setting to make all those PW Info panel icon links optionally open in a new tab - just let me know.

  • Like 1

Share this post


Link to post
Share on other sites
19 minutes ago, adrian said:

You're missing the line ending semicolon

Double bother :-X I need to think, think, think harder next time :) This is the first time I see these errors, probably I got intimidated...

19 minutes ago, adrian said:

If you are finding it that annoying though, I'd be happy to add a config setting to make all those PW Info panel icon links optionally open in a new tab - just let me know.

Yes please!

19 minutes ago, adrian said:

and use d($config);

The problem with this that I get the result in a not too tall box with lots of scrolling an clicking and the presentation of it is not as "good" as the one with the panel.

What if there was a way to put custom settings onto the Panel Selector? Meaning module settings could be enabled/disabled for the Panel Selector, those one happens to switch on/of often. Currently I have no idea how the UI could be implemented for this, so this is just a blurry thought at this time.

Edited by szabesz
typo
  • Like 1

Share this post


Link to post
Share on other sites
2 hours ago, szabesz said:

Yes please!

Ok, I'll take care of that shortly - just keep in mind that I won't be adding "_blank" to the Login/Logout, Clear Session & Cookies, and Modules Refresh links, because these are actions that are designed to reload the same page once they complete, but I think all the others will be ok with an option for "_blank".

 

2 hours ago, szabesz said:

The problem with this that I get the result in a not too tall box with lots of scrolling an clicking and the presentation of it is not as "good" as the one with the panel.

What if there was a way to put custom settings onto the Panel Selector? Meaning module settings could be enabled/disabled for the Panel Selector, those one happens to switch on/of often. Currently I have no idea how the UI could be implemented for this, so this is just a blurry thought at this time.

Honestly I think this is starting to sound a little too complex. i have already added the Enable/Disable Strict Mode option, but I think I think it could get out of control if we're not careful. I'd really like to know why $config is so slow for you - how long does the Console panel response take when doing d($config); ? Just wondering if it's rendering $config itself that's the problem, or something about the way it is done in the PW Info panel that could be improved.

  • Like 1

Share this post


Link to post
Share on other sites

A quick update.

Thanks to lots of help from @szabesz we have fixed the issue with the Config Data section in PW Info panel from being slow.

The latest version also:

1) Fixes a ERR_BLOCKED_BY_XSS_AUDITOR browser error if there are <script> tags in your template file and you are using the Template Editor panel to test code changes.

2) Adds a new option for opening links from the PW Info panel in a new browser tab (off by default) - this was requested by @szabesz above.

3) Revamped the init() and ready() code so that much less code is processed when Tracy is completely or temporarily disabled. It also improves efficiency for various conditional checks.

4) Several other minor tweaks / fixes.

Please let me know if you come across any problems with this new version.

 

  • Like 4

Share this post


Link to post
Share on other sites

@adrian This morning I quickly crafted my own version of the "TracyEnableButton" in order to see if a smaller version can be made. The idea is that – in such small sizes the icons are used – using only lines should be enough to get very similar results. Of course, when an icon like this is enlarged its line only characteristics become prominent but I do not think it is an issue in our case. So here it comes:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 54.48 57.24"><defs><style>.a{fill:none;stroke:#CD1818;stroke-miterlimit:10;stroke-width:8px;}</style></defs><title>turn-off</title><path class="a" d="M24,10.17a23.24,23.24,0,1,0,16,0" transform="translate(-4.76 -2)"/><line class="a" x1="27.24" x2="27.24" y2="21"/></svg>

Only 323 characters versus 1101 (current icon). What do you think? Is it usable, and if so worth the effort? I could produce all the others if you think it is a good idea.

  • Like 1

Share this post


Link to post
Share on other sites
6 hours ago, szabesz said:

@adrian This morning I quickly crafted my own version of the "TracyEnableButton" in order to see if a smaller version can be made. The idea is that – in such small sizes the icons are used – using only lines should be enough to get very similar results. Of course, when an icon like this is enlarged its line only characteristics become prominent but I do not think it is an issue in our case. So here it comes:


<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 54.48 57.24"><defs><style>.a{fill:none;stroke:#CD1818;stroke-miterlimit:10;stroke-width:8px;}</style></defs><title>turn-off</title><path class="a" d="M24,10.17a23.24,23.24,0,1,0,16,0" transform="translate(-4.76 -2)"/><line class="a" x1="27.24" x2="27.24" y2="21"/></svg>

Only 323 characters versus 1101 (current icon). What do you think? Is it usable, and if so worth the effort? I could produce all the others if you think it is a good idea.

I like where you are headed with this and I think the new version looks nice. The only thing I wonder is whether it is worth re-crafting all the icons vs just running them through SVGO (which I should really have already done). I just used the online GUI for this test.

I just tried and it reduced it to 501 characters:

<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 44.8 44.8">
  <g fill="#CD1818">
    <path d="M22.4 21.2c2 0 4-1.8 4-4V4c0-2-2-3.8-4-3.8s-4 1.7-4 3.8v13.5c0 2 2 4 4 4z"/>
    <path d="M30.7 3.3c-.5-.2-1 0-1.4.2-.5.3-.7.7-.7 1.3v5c0 .6.3 1.2.7 1.4 4.2 2.4 7 7 7 12 0 7.7-6.2 14-14 14-7.6 0-13.8-6.3-13.8-14 0-5 3-9.6 7-12 .4-.2.7-.8.7-1.3V4.4c0-.6-.2-1-.7-1.3C15 3 14.5 3 14 3 6.6 6.6 1 14 1 23c0 12.3 9.7 22 21.6 22 12 0 21.6-9.6 21.6-21.6 0-9-5.4-16.6-13.3-20z"/>
  </g>
</svg>

So there is definitely significant room for improvement with these icons. It's just a question of whether it's worth going the "line only" route, or just using SVGO to optimize the existing ones. Honestly I think most of the icons could do with some work - many of them are pretty ugly :) If you feel like taking this on, it would definitely be appreciated.

Anyone else have any thoughts?

  • Like 1

Share this post


Link to post
Share on other sites
1 hour ago, adrian said:

It's just a question of whether it's worth going the "line only" route, or just using SVGO to optimize the existing ones.

Line-only versions are harder to do right because of its nature and limitations but I was thinking about going crazy with optimization regarding how much is injected into the page.

1 hour ago, adrian said:

worth re-crafting all the icons vs just running them through SVGO

By removing the probably not needed <title>turn-off</title> from my version (it was just exported too, as the name of the file was "turn-off") we have only 300 characters. Probably this is not the one where we can gain a lot but more complex ones like logos and such.

1 hour ago, adrian said:

If you feel like taking this on, it would definitely be appreciated.

I would be happy to do it. It is probably not worth forcing us to use line-only svg when more complex icons are needed but some of then (like this turn on/off icon called EnableButton) looks doable. Others might just need SVGO treatment :) 

I focused on EnableButton because I would like to see less in the source code of a frontend page when Tracy is disabled. So something like this (removing some line breaks) would be nice too:

<style>div#TracyEnableButton{bottom:10px!important;right:10px!important;z-index:99999!important;position:fixed!important;width:16px!important;height:16px!important;margin:0px!important;padding:0px!important;cursor:pointer!important;}div#TracyEnableButtonsvg{width:16px!important;height:16px!important;}</style>

I often use the Chrome extension called Quick source viewer which displays the actual rendered output in a different way then the inspector. For the styles I get the line breaks but if you could remove them we would get a more compact version injected.

Edited by szabesz
fix: So something like this (removing some line breaks) would be nice too:
  • Like 1

Share this post


Link to post
Share on other sites

All sounds great @szabesz The other possibility here is to use FontAwesome icons as much as possible. I recently added it for loading the icons for the new "Custom Links" section in the PW Info panel.  Although it is only loaded if you have defined some custom links. Because you guys can add a link to any page (admin Process or frontend) on the site, this was the only way to show the appropriate icon automatically. Not sure if this is a better or worse approach in terms of resources. Obviously Fontawesome isn't super lightweight, but it's also not embedding the SVG directly into the panels, so maybe more efficient?

14 minutes ago, szabesz said:

I focused on EnableButton because I would like to see less in the source code of a frontend page when Tracy is disabled. So I this removing some line break would be nice too:

Sounds like a good idea - I'll sort that out.

  • Like 1

Share this post


Link to post
Share on other sites
1 hour ago, adrian said:

Obviously Fontawesome isn't super lightweight, but it's also not embedding the SVG directly into the panels, so maybe more efficient?

That reminds me of this tool I've somewhat forgotten about: http://fontello.com/
More efficient? Hard to tell... Maybe a custom set?

1 hour ago, adrian said:

Sounds like a good idea - I'll sort that out.

Thanks in advance! 

Share this post


Link to post
Share on other sites

I was about to suggest fontello but ten icons weighted about 10 kbyte, so 1 per char which seems heavier than svgs. Of course more or other chars can be perhaps less heavy.

Another option could be using unicode characters as icons but I'm not sure there are enough of them and browsers may display them differently. That would be super light though.

  • Like 1

Share this post


Link to post
Share on other sites
6 minutes ago, tpr said:

browsers may display them differently

Do you have any idea where it can be looked up? I mean, where we can check what is probably(?) supported by most modern OSes/browsers these days? It would be interesting to know. I guess the "cross-platform" typefaces are more or less the same as they have ever been but those font files seem to keep growing by added characters as the OSes evolve.

Share this post


Link to post
Share on other sites

I like the idea of unicode icons, but I am also not convinced that browser support is that consistent. I have seen screenshots of the Tracy console for example where the history back/forward icons don't look good. Also, I agree that there aren't enough options for our needs.

Something like a fontello custom set might be ok, but in general I have always thought that plain SVG icons were lighter, so I think I'd prefer to go with those I think. I wonder how much this really matters - is it over-optimization to be worrying about this?

Share this post


Link to post
Share on other sites

Hi @adrian,

I struck a problem trying to use bd() inside $sanitizer->pageNameUTF8().

If I add a bd() call to pageNameUTF8() like this...

public function pageNameUTF8($value) {
    bd($value, 'value');
    //...

...and then trigger the method like this...

$test = $sanitizer->pageNameUTF8('foo');

...then everything is fine so far and works as expected.

But as soon as I add the following to /site/config.php

$config->pageNameCharset = 'UTF8';

...then I get an error:

Quote

Fatal error: Uncaught Error: Call to undefined function ProcessWire\bd() in D:\Websites\__www\1testing\wire\core\Sanitizer.php:456

Any idea why this happens?

Share this post


Link to post
Share on other sites
37 minutes ago, Robin S said:

Any idea why this happens?

I think it's simply a matter of the order of things.

Without the pageNameCharset being set in config, the first call to the pageNameUTF8() sanitizer method is after init(), but when you set it, it must call that sanitizer method before Tracy has loaded. I did ask Ryan a long while back about the possibility of being able to load Tracy earlier - he said he might be amenable, but nothing ever came of it.

I just did some experiments loading the Tracy core files in the root index.php and with that setup, your bd() call still works, even with: $config->pageNameCharset = 'UTF8';

I'd like to revisit this idea with Ryan - I have come across bd() undefined many times when trying to use them in the PW core files - it would be great to have Tracy loaded before anything else.

I wonder if a request for this might be more powerful initiated by someone other than myself?

  • Like 1

Share this post


Link to post
Share on other sites

@adrian Hi,
I scanned the "docs" and could not find this tip of yours:
https://github.com/processwire/processwire-issues/issues/429#issuecomment-342976462
sounds like an important one.

Could you please consider adding it? Also, AJAX instructions are mostly in the Getting Started section which is fine but probably a dedicated "Debugging AJAX" or maybe "Working with AJAX" section with links to other related tips found on the page and additional tips like the one above would be nice to have.

Edited by szabesz
header name idea fix
  • Like 3

Share this post


Link to post
Share on other sites

Hey @szabesz - I really need to start the docs again from scratch. I have butchered that blog post so badly with new additions and most of the screenshots are really old. I'd really like to start a Github wiki for docs - @tpr has inspired me with the amazing job he has done on the docs for his modules using the wiki. The problem of course is time. I am already spending way too much time on module development and support and not enough time on paid client work - not meant to be an excuse, just a reality. And there are lots of others here putting in just as much time! 

I'd love to dedicate more time to PW module development, but of course that would mean paid modules - what to do ?

Maybe the Tracy docs could be a team effort - anyone interested? The problem is that there is no easy way to enable PRs on Gitbub wikis, although this might work: http://www.growingwiththeweb.com/2016/07/enabling-pull-requests-on-github-wikis.html

Any thoughts?

 

  • Like 3

Share this post


Link to post
Share on other sites
13 minutes ago, adrian said:

anyone interested?

+1 :)

13 minutes ago, adrian said:

The problem is that there is no easy way to enable PRs on Gitbub wikis, although this might work

I'm not fond of unsupported "hacky" solutions but it is just me :) Maybe a dedicated tool instead? I just googled a bit: https://www.penflip.com/

There could be alternatives, of course.

  • Like 1

Share this post


Link to post
Share on other sites

i don't know how the guys from uikit are doing it but they have nice docs and it seems that everybody can post suggestions (there is an edit button on all pages): https://getuikit.com/docs/icon

it's unbelievable how much you contributed to the community so far - a donation button would be the least imho. i've already asked you for that some time ago ;)

  • Like 3

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By BitPoet
      MediaLibrary
      Update: MediaLibrary can now be found in the official module list.
      Out of necessity, I've started to implement a simple media library module.
      The basic mechanism is that it adds a MediaLibrary template with file and image fields. Pages of this type can be added anywhere in the page tree.
      The link and image pickers in CKEditor are extended to allow quick selection of library pages from dropdowns. In the link picker this happens in the MediaLibrary tab, where you can also see a preview of the selected image. In the image picker, simply select a library from the dropdown at the top, everything else is handled by standard functionality.
      I've put the code onto github. This module is compatible with ProcessWire 3.
      Steps to usage:
      Download the module's zip from github (switch to the pw3 branche beforehand if you want to test on PW 3.x) and unpack it into site/modules Click "Modules" -> "Refresh" in the admin Click "Install" for MediaLibrary For testing, create a page with the MediaLibrary template under home (give it an expressive title like 'Global Media') and add some images and files Edit a differnt page with a CKEditor field and add a link and an image to see the MediaLibrary features in action (see the screencap for details) Optionally, go into the module settings for MediaLibrary Note: this module is far from being as elaborate as Kongondo's Media Manager (and doesn't plan to be). If you need a feature-rich solution for integrated media management, give it a look.
      Feel free to change the settings for MediaFiles and MediaImages fields, just keep the type as multiple.
      There are some not-so-pretty hacks for creating and inserting the correct markup, which could probably be changed to use standard input fields, though I'm a bit at a loss right now how to get it to work. I've also still got to take a look at error handling before I can call it fit for production. All feedback and pointers are appreciated (that's also why I post this in the development section).

      Edit 09.03.2016 / version 0.0.4: there's now also a "Media" admin page with a shortcut to quickly add a new library.

      Edit 01.05.2016:
      Version 0.0.8:
      - The module now supports nested media libraries (all descendants of eligible media libraries are also selectable in link/image picker).
      - There's a MediaLibrary::getPageMediaLibraries method you can hook after to modify the array of available libraries.
      - You can switch between (default) select dropdowns or radio boxes in the module configuration of MediaLIbrary to choose libraries.
      Edit 10.10.2018:
      Version 0.1.3:
      - Dropped compatibility for ProcessWire legacy versions by adding namespaces
      - Allow deletion of libraries from the Media overview admin page
      - Added an option to hide media libraries from the page tree (optionally also for superusers)
    • By Robin S
      This module corrects a few things that I find awkward about the "Add New Template" workflow in the PW admin. I opened a wishlist topic a while back because it would good to resolve some of these things in the core, but this module is a stopgap for now.
      Originally I was going to share these as a few standalone hooks, but decided to bundle them together in a configurable module instead.
      Add Template Enhancements
      A module for ProcessWire CMS/CMF. Adds some efficiency enhancements when adding or cloning templates via admin.

      Features
      Derive label from name when new template added: if you like to give each of your templates a label then this feature can save some time. The label can be added automatically when templates are added in admin, in admin/API, or not at all. There are options for underscore/hyphen replacement and capitalisation of the label. Edit template after add: when adding only a single template, the template is automatically opened for editing after it is added. Copy field contexts when cloning: this copies the field contexts (a.k.a. overrides such as column width, label and description) from the source template to the new template when using the "Duplicate/clone this template?" feature on the Advanced tab. Copy field contexts when duplicating fields: this copies the field contexts if you select the "Duplicate fields used by another template" option when adding a new template. Usage
      Install the Add Template Enhancements module.
      Configure the module settings according to what suits you.
       
      https://github.com/Toutouwai/AddTemplateEnhancements
      https://modules.processwire.com/modules/add-template-enhancements/
    • By Mike Rockett
      As I mentioned in this issue, I've create a new textformatter for ParsedownExtraPlugin, which adds some oomph to your markdown.
      Repo: Parsedown Extra Plugin
      Unlike the built-in textformatter for Parsedown and Parsedown Extra, this should be used when you want to use Extra with additional configuration/customisation.
      Some examples:
      ### Test {.heading} - A [external link](https://google.com/){.google} with `google` as a class that opens in a new tab if the config property is set. - [Another link](/page){target=_blank} that opens in a new tab even though it isn't external. ```html .html <p>Test</p> ``` There's some config options available to you, such as setting attributes on all/external images and links, setting table and table-cell alignment classes, adjusting footnote classes and IDs, adding <code> attributes to their parent <pre> elements, and changing the <code> class if your syntax highlighter does not use language-*.
      I was thinking about adding the ability to make links open in a new tab by appending a plus to the link syntax, but only external links should be opening in a new tab anyway. Further, this would add extra, unnecessary processing time.
      Please let me know if you bump into any problems. ☺️
    • By Mike Rockett
      TextformatterTypographer (0.4.0 Beta)
      A ProcessWire wrapper for the awesome PHP Typography class, originally authored by KINGdesk LLC and enhanced by Peter Putzer in wp-Typography. Like Smartypants, it supercharges text fields with enhanced typography and typesetting, such as smart quotations, hyphenation in 59 languages, ellipses, copyright-, trade-, and service-marks, math symbols, and more.
      Learn more on my blog
      It's based on the PHP-Typography library found over at wp-Typography, which is more frequently updated and feature rich that its original by KINGdesk LLC.
      The module itself is fully configurable. I haven't done extensive testing, but there is nothing complex about this, and so I only envisage a typographical bug here and there, if any.
      Please do test it out and let me know what you think.
      Also note that I have indicated support for PW 2.8, but I haven't tested there as yet. This was built on PW 3.0.42/62.
    • By Mike Rockett
      Jumplinks for ProcessWire
      Release: 1.5.50
      Jumplinks is an enhanced version of the original ProcessRedirects by Antti Peisa.
      The Process module manages your permanent and temporary redirects (we'll call these "jumplinks" from now on, unless in reference to redirects from another module), useful for when you're migrating over to ProcessWire from another system/platform. Each jumplink supports wildcards, shortening the time needed to create them.
      Unlike similar modules for other platforms, wildcards in Jumplinks are much easier to work with, as Regular Expressions are not fully exposed. Instead, parameters wrapped in curly braces are used - these are described in the documentation.
      Under Development: 2.0, to be powered by FastRoute
      As of version 1.5.0, Jumplinks requires at least ProcessWire 2.6.1 to run.
      View on GitLab
      Download via the Modules Directory
      Read the docs
      Features
      The most prominent features include:
      Basic jumplinks (from one fixed route to another) Parameter-based wildcards with "Smart" equivalents Mapping Collections (for converting ID-based routes to their named-equivalents without the need to create multiple jumplinks) Destination Selectors (for finding and redirecting to pages containing legacy location information) Timed Activation (activate and/or deactivate jumplinks at specific times) 404-Monitor (for creating jumplinks based on 404 hits) Additionally, the following features may come in handy:
      Stale jumplink management Legacy domain support for slow migrations An importer (from CSV or ProcessRedirects) Feedback & Feature Requests
      I’d love to know what you think of this module. Please provide some feedback on the module as a whole, or even regarding smaller things that make it whole. Also, please feel free to submit feature requests and their use-cases.
      Note: Features requested so far have been added to the to-do list, and will be added to 2.0, and not the current dev/master branches.
      Open Source

      Jumplinks is an open-source project, and is free to use. In fact, Jumplinks will always be open-source, and will always remain free to use. Forever. If you would like to support the development of Jumplinks, please consider making a small donation via PayPal.
      Enjoy!