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

Issues with monitor updates #18

Open
BiggestGoos opened this issue Oct 15, 2024 · 9 comments
Open

Issues with monitor updates #18

BiggestGoos opened this issue Oct 15, 2024 · 9 comments
Labels
bug Something isn't working windows The problem happens in Windows

Comments

@BiggestGoos
Copy link

BiggestGoos commented Oct 15, 2024

This happens on Windows 10 with Anki

  • Version ⁨23.12.1 (1a1d4d54)⁩
  • Python 3.9.15 Qt 6.6.1 PyQt 6.6.1

Whenever my monitor turns off (goes into sleep mode) or I change any sort of setting such as resolution or scale while Anki is minimized using this plugin, the main Anki window reappears (only the main window it seems). After this, both the X button on the window as well as the 'Show all windows' button on the tray icon popup stops working. The main window also seems to stop updating the viewport size which means that when the window is resized, all buttons and text becomes offset like this: (The offset buttons also stop working when this happens.)
not_good

I realized that if you change the scale of the monitor to make this happen and then change it back to the old one then the buttons start working again but they still become offset when the window is resized. The button selection still doesn't work either.

I also managed to produce this error: (only once though and I'm not sure how to reproduce, I was just messing around with the tray icon after I hade changed my monitor settings)

'Anki 23.12.1 (1a1d4d54) (ao)
Python 3.9.15 Qt 6.6.1 PyQt 6.6.1
Platform: Windows-10-10.0.19045

Traceback (most recent call last):
File "C:\Users\user\AppData\Roaming\Anki2\addons21\85158043_init_.py", line 71, in showAll
self.showWindows(self.explicitlyHiddenWindows)
File "C:\Users\user\AppData\Roaming\Anki2\addons21\85158043_init
.py", line 88, in _showWindows
if w.isMinimized() == Qt.WindowState.WindowMinimized:
RuntimeError: wrapped C/C++ object of type CustomLabel has been deleted'

Also here are my active addons incase they might be part of the issue. (It might be worth testing this without any other addons active.)

'Anki Preview Reloader ['571150035', 2023-11-20T20:15, '1.0.1', '']
AnkiConnect ['2055492159', 2024-07-26T06:55, 'None', mod]
AnkiWebView Inspector ['31746032', 2023-06-27T21:26, 'None', '']
Contanki - Controller Support for Anki beta ['1898790263', 2024-03-01T02:22, 'v1.0.2', '']
Deck duplication ['1779572689', 2022-06-11T16:24, 'None', '']
FSRS Helper Postpone Advance Load Balance Easy Days Disperse Siblings ['759844606', 2024-10-10T04:36, 'None', mod]
HyperTTS - Add speech to your flashcards ['111623432', 2024-10-04T04:54, 'None', mod]
Local Audio Server for Yomichan ['1045800357', 2023-06-19T05:57, 'None', '']
Minimize to tray ['85158043', 2023-11-26T20:18, 'None', '']
OpenInExternalEditorRenameDuplicate for ImageAudioVideo WinLinux ['1560623518', 2023-03-19T18:33, 'None', '']
Review Heatmap ['1771074083', 2022-06-30T03:43, 'None', '']'

@simgunz
Copy link
Owner

simgunz commented Oct 30, 2024

Regarding your last error I have implemented a fix that should fix it. I'll release it soon.

Regarding the viewport size, I suspect that is an Anki upstream bug. Does it happen in this cases?

  • all addons disabled
  • only minimize to tray addon disabled

Same question for the 'Show all windows' buttons not working, can you try out with the two conditions above?

@BiggestGoos
Copy link
Author

Same question for the 'Show all windows' buttons not working, can you try out with the two conditions above?

I'm not really sure how I would test the 'Show all windows' button when "all addons [are] disabled" or the "minimize to tray addon [is] disabled"?

Regarding the viewport size, I am only experiencing it when 'Minimize to tray' is enabled and other addons don't seem to affect it.

I just now realized that all of these problems only seem to occur when an Anki window is maximized (I don't know how I didn't notice sooner). When any Anki window (including things like the browse window it seems) are maximized then, whenever Anki is currently minimized to tray and the monitor changes in some way (e.g. resolution is changed or goes into sleeping mode), the maximized windows reappear without me prompting them to, and they (sometimes, sometimes not,) become a bit weird with a black bar at the bottom. After they have reappeared, those windows don't work like normally anymore.

I also tried to see if the windows being minimized had any effect but it seems to work completely as expected when that is the case.

I also just now realized that if I press the tray icon after a window has reappeared like I described, the window is fixed and returns to normal. This only seems to work if the X button isn't pressed first. If the X button is pressed before doing so it seems that the window can't be returned to normal and the only solution I have found is to restart Anki.

These two last points were tested with only the 'Minimize to tray' addon enabled. All the problems only seemed to occur, as described, when a window was maximized.

I also managed to produce another error that seems similar to the last one I posted:

'Anki 23.12.1 (1a1d4d54) (ao)
Python 3.9.15 Qt 6.6.1 PyQt 6.6.1
Platform: Windows-10-10.0.19045

Traceback (most recent call last):
File "C:\Users\user\AppData\Roaming\Anki2\addons21\85158043_init_.py", line 53, in onActivated
self.showAll()
File "C:\Users\user\AppData\Roaming\Anki2\addons21\85158043_init_.py", line 71, in showAll
self.showWindows(self.explicitlyHiddenWindows)
File "C:\Users\user\AppData\Roaming\Anki2\addons21\85158043_init
.py", line 88, in _showWindows
if w.isMinimized() == Qt.WindowState.WindowMinimized:
RuntimeError: wrapped C/C++ object of type Browser has been deleted

===Add-ons (active)===
(add-on provided name [Add-on folder, installed at, version, is config changed])
Minimize to tray ['85158043', 2023-11-26T20:18, 'None', '']'

I find that the way to produce this specific error is to have the browse window maximized (it seems that it doesn't matter if the main window is maximized or not), then I close the main window so that anki is minimized to tray, then I update a monitor setting and after the browse window has reappeared (like how I have described earlier) I close the browse window. After that I then click the Anki tray icon and this error occurs.

For now, a simple solution for me seems to be to not have Anki maximized when I minimize it to tray.

@simgunz
Copy link
Owner

simgunz commented Dec 18, 2024

RuntimeError: wrapped C/C++ object of type CustomLabel has been deleted'

I have just released a 2.0.1 version, where I attempted to fix this type of crash. Can you test it?

@BiggestGoos
Copy link
Author

I tried doing what I described to produce the crash and it seems like you might have fixed that. The other problems that I described earlier still seem to persist though. I can also say that I am now using Anki 'Version ⁨24.11 (87ccd24e)⁩
Python 3.9.18 Qt 6.6.2 PyQt 6.6.1'.

@simgunz
Copy link
Owner

simgunz commented Dec 22, 2024

Thanks for the feedback. I will try to find the time to look into the other problem at some point.

@simgunz
Copy link
Owner

simgunz commented Jan 12, 2025

Scenario 1 - Main Window Issue with resolution change (confirmed):
Steps to reproduce the problem:

  1. Maximize any Anki window
  2. Minimize Anki to tray using the plugin
  3. Change the monitor resolution

Result:

  • Main window re-appear
  • (if the new vertical resolution is lower than the previous one a black bar bar appears at the bottom of the anki window)
  1. Click the X button of the main window (this triggers the problem)

Result:

  • X button and 'Show all windows' button stop working
  • If the main window is minimized the content is not displayed correctly

Scenario 2 - Workaround (confirmed)
Steps to reproduce the problem:

  1. Maximize any Anki window
  2. Minimize Anki to tray using the plugin
  3. Change the monitor resolution

Result: Main window re-appear

  1. Click the tray icon before clicking the X button of the main window

Result: Things keep working

Scenario 3 - Main Window Issue with monitor sleep (cannot reproduce)
Steps to reproduce the problem:

  1. Maximize any Anki window
  2. Minimize Anki to tray using the plugin
  3. Let the notebook monitor turn off after an idle time (1 minute)

Result: Main window re-appear

@simgunz
Copy link
Owner

simgunz commented Jan 12, 2025

I have tested a few of the reported scenario.

I cannot reproduce the Scenario 3, which is the only one I deem critical. Are the steps I wrote for Scenario 3 correct?

I can reproduce the other two scenarios on Windows.
The problem does not appear under KDE Plasma wayland.

@simgunz simgunz added bug Something isn't working windows The problem happens in Windows labels Jan 12, 2025
@BiggestGoos
Copy link
Author

On scenario 3, there doesn't seem to be an immediate problem as in, if I let the monitor sleep and then immediately wake it then nothing happens with anki but if I leave my computer on for an extended amount of time then I experience the issue. I don't know why or how long.

@simgunz
Copy link
Owner

simgunz commented Jan 13, 2025

Thanks for the extra info. I'll try to understand the underlying problem, though it seems to be a tricky one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working windows The problem happens in Windows
Projects
None yet
Development

No branches or pull requests

2 participants