kint-php / kint

Kint - Advanced PHP dumper
https://kint-php.github.io/kint/
MIT License
2.77k stars 291 forks source link

Is it possible Kint to be made Turbolinks friendly? #340

Closed ivantcholakov closed 4 years ago

ivantcholakov commented 4 years ago

https://github.com/turbolinks/turbolinks

Turbolinks JavaScript makes page loading extremely fast, this usage scenario is really wothwhile to be kept in mind. But currently some Kint's Javascript crash when I use Turbolinks and unfortunately I had to turn Kint off. Is is possible Kint to be adapted to work under Turbolinks too?

jnvsor commented 4 years ago

I've never used it so I don't know what's going wrong. Do you have an error in the console? Can you set up a demo page where it crashes?

ivantcholakov commented 4 years ago

I develop an application starter with CodeIgniter 4 that uses Kint. https://github.com/ivantcholakov/starter-public-edition-5

Enabling the debugging bar: platform/applications/front/Config/Boot/development.php :

defined('CI_DEBUG') || define('CI_DEBUG', true);    // This turns Kint on.

And here is what I see:

image

image

With

defined('CI_DEBUG') || define('CI_DEBUG', false);

I turn the debugging bar off to deal with this error.

Turbolinks has for exmple its own event system, because it works with AJAX calls (except for the first loaded pages). Events like 'turbolinks:load', 'turbolinks:render'. I guess if Turbolinks presense is detected and some Javascripts get slightly adapted there is a chance for success. But I can't do this alone.

Turbolinks is worthwhile, it makes pages very fast! Actually, it almost makes JavaScript frameworks useless.

I will make very soon another alpha release and I will notify you, so you can have a tagged code to see the problem.

jnvsor commented 4 years ago

"Maximum call stack size exceeded" with a call stack that seems to be going through new newXHR over and over looks like an issue in that debugbar, rather than in kint.

The only other potential culprit would have to be the initialization code run on load event. Normally that should only happen once, and I have no idea what turbolinks is doing with it, though according to their documentation it should work just fine.

I'll wait for you to have some demo code for me to look at

Edit: Can you try turning debug off and dumping something with kint manually? If that works then that proves it's an issue with the debugbar, not kint.

ivantcholakov commented 4 years ago

https://github.com/ivantcholakov/starter-public-edition-5/releases/tag/v5.0.0-alpha.7

Installation:

CI_ENVIRONMENT = development



And then the debugging bar (or a small icon, bottom-right) would be visible. Click on some pages and the JavaScript crash would be seen.

I will try to examine what can be done, but I am not confident about the result. I am getting familiar with this technology these days.
ivantcholakov commented 4 years ago

I will try to debug alone, if I find something useful I'll let you know. I don't know whether the debug bar is part of your project or not, excuse me if I addressed the issue to a wrong place.

jnvsor commented 4 years ago

I don't know whether the debug bar is part of your project or not

It's not, kint just provides the dumper. Debug bars tend to provide more integrated information in a framework.

Try disabling your debug and putting this in a page:

\Kint::$enabled_mode = true;
\Kint::dump('test');

If kint shows up on the page and nothing explodes then it's the debug bar that's broken.

I can't get your repo working here, so I can't debug any further.

PS: You should put your vendor folder in your .gitignore - only commit the composer.json and composer.lock, it makes for a cleaner repo history

ivantcholakov commented 4 years ago

I tested you piece of code and nothing exploded. So, the problem is not here. Thank you for your kindness.

ivantcholakov commented 4 years ago

Somehow I've made a patch, the debugging bar refreshes its data only when the page is refreshed, but at least this is something. Thank you once again. :)