Hi guys!

For a long time (apologies for not reporting it until now) - the webprofiler - on multiple projects and versions of Drupal 8.x - has shown 0ms with no graph for the timeline in the profiler. This seemed so obviously broken, that I assumed that it's something wrong with my setup. But, if it is, I keep making some mistake over and over again - this never works for me :/.

Attached is a screenshot of how it looks. The "time" data coming from the profiler *is* all 0.

Thanks!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

weaverryan created an issue. See original summary.

weaverryan’s picture

The reason things are zero is because the profiler is *started* in the TraceableContainer. If you don't enable that, it never starts.

However, even after enabling it, I see a lot of errors - it's as if this feature just isn't working.

Can anyone confirm that - after enabling the TraceableContainer as described in the README - that they can or cannot see a working timeline in the profiler?

lussoluca’s picture

Hi Ryan,
did you add:

$class_loader->addPsr4('Drupal\\webprofiler\\', [ __DIR__ . '/../../modules/contrib/devel/webprofiler/src']);
$settings['container_base_class'] = '\Drupal\webprofiler\DependencyInjection\TraceableContainer';

to settings.php?
Which kind of errors do you receive? On which version of Drupal?

fgm’s picture

@lussoluca: with an equivalent line (different path) in settings.local.php, the duration is indeed no longer 0 (Total time 344.6 ms Initialization time 21.6 ms), but it still doesn't show the usual SF2 timeline. No error, and nothing in logs.

lussoluca’s picture

Have you added the d3.js library to your project? Take a look at the module README.MD.

With the latest 8.x-1.x-dev and a Composer based workflow the download of d3.js is automatic.

fgm’s picture

Yes, I have added the libraries manually, the requirements no longer show either of them as missing, yes I'm using a composer-based workflow, and no, neither library is downloaded automatically.

AFAIK this only works for PHP libraries, unless specific JS-related magic. I tried adding the repos to the project-level composer.json and add a dependency, but then the downloads produced the source repositories, meaning an extra JS builder step would have been necessary.

Actually, in the meantime, I have a number of situations where the WebProfiler causes fatals, mostly because it tries to invoke WrappedListener::getSubscribedEvents(), but WrappedListener does not implement EventSubscriberInterface. This happens notably on error pages, during handling KernelEvents::TERMINATE.

lussoluca’s picture

Did you have any javascript errors?

Actually, in the meantime, I have a number of situations where the WebProfiler causes fatals, mostly because it tries to invoke WrappedListener::getSubscribedEvents(), but WrappedListener does not implement EventSubscriberInterface. This happens notably on error pages, during handling KernelEvents::TERMINATE.

Feel free to open a new issue for this other problem.

fgm’s picture

Just one JS error: "Uncaught TypeError: Cannot read property 'linear' of undefined". (multiple times).

lussoluca’s picture

What is the output of

drupalSettings.webprofiler.time

in your browser javascript console?

fgm’s picture

FileSize
59.92 KB

See image for details.

lussoluca’s picture

Are you using d3.js version 4?
It seems that a lot of APIs were changed in this version.

If so, could you please try with d3.js version 3? I'll update documentation to point out that Webprofiler works only with d3.js version 3 for now.

fgm’s picture

Status: Active » Needs review
FileSize
510 bytes

Good catch. I had 4.2.2. Switching to 3.5.17 did the trick. Attached is a tiny README patch for this.

  • lussoluca committed 44f663d on 8.x-1.x authored by fgm
    Issue #2721363 by fgm: webprofiler timeline always reports 0, no graph
    
lussoluca’s picture

Status: Needs review » Closed (fixed)

Committed and pushed to 8.x-1.x

Thanks a lot!

Status: Closed (fixed) » Needs work

The last submitted patch, 12: 2721363-d3-3.patch, failed testing.

lussoluca’s picture

Status: Needs work » Closed (fixed)
fgm’s picture

Note that this doesn't fix the fatal errors like the one below, just the lack of a timeline display when things go well otherwise. But as you said, maybe this is another issue entirely:

Error: Call to a member function getReasonPhrase() on null in Drupal\webprofiler\DataCollector\HttpDataCollector->collect() (line 106 of modules/contrib/devel/webprofiler/src/DataCollector/HttpDataCollector.php).
Drupal\webprofiler\DataCollector\HttpDataCollector->collect(Object, NULL, NULL) (Line: 223)
Symfony\Component\HttpKernel\Profiler\Profiler->collect(Object, Object, NULL) (Line: 128)
Symfony\Component\HttpKernel\EventListener\ProfilerListener->onKernelResponse(Object, 'kernel.response', Object)
call_user_func(Array, Object, 'kernel.response', Object) (Line: 61)
Symfony\Component\EventDispatcher\Debug\WrappedListener->__invoke(Object, 'kernel.response', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.response', Object) (Line: 140)
Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->dispatch('kernel.response', Object) (Line: 184)
Symfony\Component\HttpKernel\HttpKernel->filterResponse(Object, Object, 1) (Line: 166)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 64)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 98)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 77)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 43)
Drupal\webprofiler\StackMiddleware\WebprofilerMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 628)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
lussoluca’s picture

@fgm I've opened a new issue: #2791749: Call to a member function getReasonPhrase() on null, could you please try the attached patch?

fgm’s picture

The error in #2791749: Call to a member function getReasonPhrase() on null no longer occurs these days on 8.3.4.

One thing I noticed, though, is that the instructions in the README are not always accurate: if settings.local.php is at the end of a symlink, the directory used in the addPsr4() call may not be correct, so it is safer to always use an absolute path, or at least make sure the path resolves correctly.