Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Console doesn't print current variable content for Object types (bug in console-feed) #1203

Open
WHGZIM opened this issue Oct 25, 2019 · 20 comments

Comments

@WHGZIM
Copy link

WHGZIM commented Oct 25, 2019

Nature of issue?

  • Found a bug

Details about the bug:

  • Web browser and version:

Google Chrome | 77.0.3865.120 (Offizieller Build) (64-Bit) (cohort: Stable)

  • Operating System:
    Windows
  • Steps to reproduce this bug:
    Run the Programm and load ergebnisse.txt

copy:
Otto, 345
Klaus, 23454
Leonie, 234
to ergebnisse.txt file
Run: https://editor.p5js.org/ZIM/sketches/6NUFu7ELU
Load ergebnisse.txt

Open Chrome developer Console.
Chrome developer Console shows different Values (the right ones) of an Arrays compared to p5js Web Editor Console. (Compare 9th and 10th line of output of p5js
P5JSConsoleShowsWrongArrayContent
web editor Console)

Feature enhancement details:

New feature details:

@welcome
Copy link

welcome bot commented Oct 25, 2019

Welcome! 👋 Thanks for opening your first issue here! And to ensure the community is able to respond to your issue, be sure to follow the issue template if you haven't already.

@WHGZIM WHGZIM changed the title Console prints not current Array content web edior console does not prints current array content Oct 25, 2019
@WHGZIM WHGZIM changed the title web edior console does not prints current array content p5js web editor console doesn't print current array content Oct 25, 2019
@catarak
Copy link
Member

catarak commented Oct 31, 2019

thanks for reporting! what a strange bug. not sure what's going on here!

@WHGZIM
Copy link
Author

WHGZIM commented Nov 6, 2019

I have the feeling that it is somehow related to the fact that javascript works asynchronously. While the print function is preparing the output the programm goes on and starts to sort the content of the array. At some point ,while the sorting process is still in progress, the print function comes back and catches the data of array, which is now partly sorted.

@catarak
Copy link
Member

catarak commented Nov 7, 2019

I think you're right! I was trying to demonstrate to a student yesterday how Arrays work (vs primitive types in JS) and came across the same bug. Here's an example sketch that demonstrates it.

@krawc
Copy link

krawc commented Nov 14, 2019

A potentially similar issue was reported on main p5.js repo. The exact same code worked correctly on codepen.io and incorrectly in the p5 Editor.

processing/p5.js#4143

@krawc
Copy link

krawc commented Nov 15, 2019

Print outputs are correct in the Chrome console (78.0.3904.87).

In case it helps narrow down the issue: wrapping the array value change in a 1ms timeOut gives correct outputs. Example

@catarak
Copy link
Member

catarak commented Nov 20, 2019

hehe "vile but correct". thanks for figuring that out, that's super helpful!

@ashu8912
Copy link
Contributor

The Problem here is array is a reference type object so when we are doing console.log(arr) it is actually showing content from the prototype of that array i dont know why this is happening like this can be a problem with how arrays or console.log are looked in the by web editor compiler.

this sketch code can help you understand the problem better
https://editor.p5js.org/ashughildiyal5/sketches/uki5gg_4s

@ashu8912
Copy link
Contributor

ashu8912 commented Feb 1, 2020

This is a problem with the library "console-feed" even codesandbox and other users of this library has this problems.

@ashu8912
Copy link
Contributor

ashu8912 commented Feb 1, 2020

@catarak I think this issue can be closed for now or if somebody can suggest a better logging library(that doesn't has this problem) would solve this

@catarak
Copy link
Member

catarak commented Mar 24, 2020

A possible solution is disabling serialization.

@joshuahhh
Copy link

It's very easy to run into this bug when trying to explain array mutation to new programmers. Here's a screenshot showing some code, the web-editor console, and the browser console. You can clearly see the divergence between the web-editor console and browser console.

Screen Shot 2020-05-16 at 4 55 45 PM

@ashu8912 – I am not sure what the issue-closing policy is for this project, but I would appreciate keeping this issue open as long as the problem persists. (There are, after all, multiple possible fixes, including: fixing the bug in console-feed, using console-feed in a different way, switching away from console-feed.)

Thanks!

@catarak
Copy link
Member

catarak commented Feb 10, 2021

I think unfortunately this is an issue with console-feed. That library would need to be fixed in order for it to be fixed here.

@catarak catarak changed the title p5js web editor console doesn't print current array content Console doesn't print current variable content for Object types (bug in console-feed) Feb 10, 2021
@joshuahhh
Copy link

I've submitted a PR to console-feed which ought to get us out of this trouble: samdenty/console-feed#77. If & when it gets through, I can fix this pt.js-web-editor issue.

@catarak
Copy link
Member

catarak commented Sep 13, 2021

I just checked this with the latest version of console-feed (v3.2.0). It still doesn't work 🙃

@raclim raclim closed this as completed Jan 19, 2024
@raclim
Copy link
Collaborator

raclim commented Jan 19, 2024

I'm checking now and I believe that it's working correctly for me, so I'm closing this for now!

@joshuahhh
Copy link

@raclim It's not working for me!

Screenshot 2024-01-19 at 7 50 19 PM

Same behavior as my post in 2020. Are you getting something different?

@joshuahhh
Copy link

Hi @raclim, did you see #1203 (comment)? I don't want this issue to get lost if it hasn't actually been fixed! Thanks.

@joshuahhh
Copy link

Ping on this, @raclim. Or please let me know if I should stop bothering you. 🙏

@raclim
Copy link
Collaborator

raclim commented Nov 13, 2024

I'm so sorry @joshuahhh for not seeing these!!! I think your pings ended up getting lost a while back 😭 You're correct that it actually hasn't been resolved. I'm going to reopen this and try to see if a workaround could be found!

@raclim raclim reopened this Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants