Kragrathea / OctoPrint-PrettyGCode

114 stars 20 forks source link

After upgrading Octoprint to version 1.10.0 PrettyGCode shows empty window #160

Open anderl1969 opened 4 months ago

anderl1969 commented 4 months ago

After upgrading Octoprint to 1.10.0 the PGcode-plugin most of the time doesn't work:

Sometimes the plugin works as usual, but most of the time it doesn't.

Rylan-Meilutis commented 4 months ago

It appears to be an issue with the way the js gets the volume of the bed, here is the error in the chrome logs

packed_core.js?8d71fd9c:1828 Error calling onTabChange on view model PrettyGCodeViewModel : Cannot read properties of undefined (reading 'volume')
TypeError: Cannot read properties of undefined (reading 'volume')
    at updateBedVolume (https://octoprint.rylanswebsite.com/static/webassets/packed_plugins.js?47991bcf:52262:75)
    at PrettyGCodeViewModel.self.onTabChange (https://octoprint.rylanswebsite.com/static/webassets/packed_plugins.js?47991bcf:52046:29)
    at callViewModelIf (https://octoprint.rylanswebsite.com/static/webassets/packed_core.js?8d71fd9c:1827:75)
    at https://octoprint.rylanswebsite.com/static/webassets/packed_core.js?8d71fd9c:1821:138
    at Pn (https://octoprint.rylanswebsite.com/static/webassets/packed_libs.js?409a9b49:30:530)
    at Function.<anonymous> (https://octoprint.rylanswebsite.com/static/webassets/packed_libs.js?409a9b49:51:66)
    at callViewModelsIf (https://octoprint.rylanswebsite.com/static/webassets/packed_core.js?8d71fd9c:1821:95)
    at callViewModels (https://octoprint.rylanswebsite.com/static/webassets/packed_core.js?8d71fd9c:1820:56)
    at OctoPrint.coreui.exports.onTabChange (https://octoprint.rylanswebsite.com/static/webassets/packed_core.js?8d71fd9c:1854:47)
    at HTMLAnchorElement.<anonymous> (https://octoprint.rylanswebsite.com/static/webassets/packed_core.js?8d71fd9c:1877:1896)

and here is where that line is in the code

cansinacarer commented 4 months ago

I have the same issue.

Rylan-Meilutis commented 4 months ago

Right now I am in school for about the next 3 weeks, if school lets out and there has been no reply I will fork this repo and try to resolve the issue.

gitolicious commented 4 months ago

What I found: Navigating to the start page http://octoprint:5000/ (or any other tab), then clicking on the PrettyGCode button, everything works fine. Opening the tab directly with http://octoprint:5000/#tab_plugin_prettygcode leads to the above error because the self.printerProfiles are not populated.

jacopotediosi commented 2 months ago

The culprit here is that the printer profiles are asynchronous and it is not certain that they have already been populated when the PrettyGCode tab is opened. When the tab is opened, this plugin tries to call the updateBedVolume() function, which tries to access the printer profiles and crashes because they are not yet populated.

In fact, as also noted by @gitolicious, if the tab is opened when the OctoPrint web page is already completely loaded, the printer profiles are already populated and this bug does not occur, while if the page is loaded directly on the tab, they are not yet ready:

Navigating to the start page http://octoprint:5000/ (or any other tab), then clicking on the PrettyGCode button, everything works fine. Opening the tab directly with http://octoprint:5000/#tab_plugin_prettygcode leads to the above error because the self.printerProfiles are not populated.

The OctoPrint default temperature graph was having (almost) the same issue in OctoPrint 1.10.0rc3: https://github.com/OctoPrint/OctoPrint/issues/4980#issuecomment-2031357981

My PR #163 should fix this. In the meantime, you should be able to try my patched plugin version by installing the following URL via the OctoPrint plugin manager: https://github.com/jacopotediosi/OctoPrint-PrettyGCode/archive/patch-1.zip

rdenis1 commented 2 months ago

The culprit here is that the printer profiles are asynchronous and it is not certain that they have already been populated when the PrettyGCode tab is opened. When the tab is opened, this plugin tries to call the updateBedVolume() function, which tries to access the printer profiles and crashes because they are not yet populated.

In fact, as also noted by @gitolicious, if the tab is opened when the OctoPrint web page is already completely loaded, the printer profiles are already populated and this bug does not occur, while if the page is loaded directly on the tab, they are not yet ready:

Navigating to the start page http://octoprint:5000/ (or any other tab), then clicking on the PrettyGCode button, everything works fine. Opening the tab directly with http://octoprint:5000/#tab_plugin_prettygcode leads to the above error because the self.printerProfiles are not populated.

The OctoPrint default temperature graph was having (almost) the same issue in OctoPrint 1.10.0rc3: OctoPrint/OctoPrint#4980 (comment)

My PR #163 should fix this. In the meantime, you should be able to try my patched plugin version by installing the following URL via the OctoPrint plugin manager: https://github.com/jacopotediosi/OctoPrint-PrettyGCode/archive/patch-1.zip

Your fix works great!

KevWal commented 1 month ago

Just a +1 your fix works for me too, thank you!

darkvertex commented 1 month ago

I too confirm the fix works. Thank you! 😄