pannal / plex-for-kodi

Unoffical Plex for Kodi add-on releases.
GNU General Public License v2.0
236 stars 30 forks source link

After returns from suspend mode freezing Plex in CoreElec #124

Closed evertonmdz closed 2 days ago

evertonmdz commented 3 days ago

Description: Another problem that I notice in CoreElec, which does not happen on Android, is when it returns from suspend mode it stays on this screen, it freezes and then you have to restart Coreelec. It is some bug related to returning from suspend mode.

Details:

Add-on version: 0.7.8 Kodi version: 21.0 Omega OS Platform: CoreElec Kernel 5.4.210 Hardware: Tox3 S905x4/c2 CoreELEC-Amlogic-ne.aarch64-21.0-Omega-Generic.img.gz

Checklist

20240704_091115 log-2024-07-04-12.11.53.zip log-2024-07-04-12.17.12.zip

Congratulations on supporting the Addon to this day, even on CoreElec, thanks to you we have a usable Plex on Kodi! I think it's much better than using Kodi or Plex on Android.

pannal commented 3 days ago

Yeah, the network connectivity isn't there, yet, at that state:

2024-05-02 00:34:36.466 T:1607    error <general>: _________________________________________________________________________________
2024-05-02 00:34:36.466 T:1607    error <general>: script.plex: ERROR: 
2024-05-02 00:34:36.466 T:1607    error <general>:     Traceback (most recent call last):
2024-05-02 00:34:36.466 T:1607    error <general>:       File "/storage/.kodi/addons/script.plexmod/lib/_included_packages/plexnet/plexserver.py", line 236, in query
2024-05-02 00:34:36.466 T:1607    error <general>:         response = method(url, **kwargs)
2024-05-02 00:34:36.466 T:1607    error <general>:                    ^^^^^^^^^^^^^^^^^^^^^
2024-05-02 00:34:36.466 T:1607    error <general>:       File "/storage/.kodi/addons/script.module.requests/lib/requests/sessions.py", line 602, in get
2024-05-02 00:34:36.466 T:1607    error <general>:         return self.request("GET", url, **kwargs)
2024-05-02 00:34:36.466 T:1607    error <general>:                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-05-02 00:34:36.466 T:1607    error <general>:       File "/storage/.kodi/addons/script.module.requests/lib/requests/sessions.py", line 589, in request
2024-05-02 00:34:36.466 T:1607    error <general>:         resp = self.send(prep, **send_kwargs)
2024-05-02 00:34:36.466 T:1607    error <general>:                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-05-02 00:34:36.466 T:1607    error <general>:       File "/storage/.kodi/addons/script.module.requests/lib/requests/sessions.py", line 703, in send
2024-05-02 00:34:36.466 T:1607    error <general>:         r = adapter.send(request, **kwargs)
2024-05-02 00:34:36.466 T:1607    error <general>:             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-05-02 00:34:36.466 T:1607    error <general>:       File "/storage/.kodi/addons/script.module.requests/lib/requests/adapters.py", line 486, in send
2024-05-02 00:34:36.466 T:1607    error <general>:         resp = conn.urlopen(
2024-05-02 00:34:36.466 T:1607    error <general>:                ^^^^^^^^^^^^^
2024-05-02 00:34:36.466 T:1607    error <general>:       File "/storage/.kodi/addons/script.module.urllib3/lib/urllib3/connectionpool.py", line 790, in urlopen
2024-05-02 00:34:36.466 T:1607    error <general>:         response = self._make_request(
2024-05-02 00:34:36.466 T:1607    error <general>:                    ^^^^^^^^^^^^^^^^^^^
2024-05-02 00:34:36.466 T:1607    error <general>:       File "/storage/.kodi/addons/script.module.urllib3/lib/urllib3/connectionpool.py", line 467, in _make_request
2024-05-02 00:34:36.466 T:1607    error <general>:         self._validate_conn(conn)
2024-05-02 00:34:36.466 T:1607    error <general>:       File "/storage/.kodi/addons/script.module.urllib3/lib/urllib3/connectionpool.py", line 1096, in _validate_conn
2024-05-02 00:34:36.466 T:1607    error <general>:         conn.connect()
2024-05-02 00:34:36.466 T:1607    error <general>:       File "/storage/.kodi/addons/script.module.urllib3/lib/urllib3/connection.py", line 611, in connect
2024-05-02 00:34:36.466 T:1607    error <general>:         self.sock = sock = self._new_conn()
2024-05-02 00:34:36.466 T:1607    error <general>:                            ^^^^^^^^^^^^^^^^
2024-05-02 00:34:36.466 T:1607    error <general>:       File "/storage/.kodi/addons/script.plexmod/lib/_included_packages/plexnet/asyncadapter.py", line 157, in _new_conn
2024-05-02 00:34:36.466 T:1607    error <general>:         sock = self.create_connection(
2024-05-02 00:34:36.466 T:1607    error <general>:                ^^^^^^^^^^^^^^^^^^^^^^^
2024-05-02 00:34:36.466 T:1607    error <general>:       File "/storage/.kodi/addons/script.plexmod/lib/_included_packages/plexnet/asyncadapter.py", line 118, in create_connection
2024-05-02 00:34:36.466 T:1607    error <general>:         for msg in self._connect(sock, sa):
2024-05-02 00:34:36.466 T:1607    error <general>:       File "/storage/.kodi/addons/script.plexmod/lib/_included_packages/plexnet/asyncadapter.py", line 138, in _connect
2024-05-02 00:34:36.466 T:1607    error <general>:         self._check_timeout()  # this should be done at the beginning of each loop
2024-05-02 00:34:36.466 T:1607    error <general>:         ^^^^^^^^^^^^^^^^^^^^^
2024-05-02 00:34:36.466 T:1607    error <general>:       File "/storage/.kodi/addons/script.plexmod/lib/_included_packages/plexnet/asyncadapter.py", line 88, in _check_timeout
2024-05-02 00:34:36.466 T:1607    error <general>:         raise TimeoutException('connection timed out')
2024-05-02 00:34:36.466 T:1607    error <general>:     plexnet.asyncadapter.TimeoutException: connection timed out
2024-05-02 00:34:36.466 T:1607    error <general>: _________________________________________________________________________________

After which PM4K basically dies and takes your OS with it.

I have a couple of areas I can try to address this in.

You could try setting "Maximum wait time for network" from "Off" to something higher, maybe that fixes it already (Kodi Settings/System).

pannal commented 3 days ago

Also I think our retry handling never worked for Timeout Errors. The next beta will have a potential fix for this.

evertonmdz commented 3 days ago

Also I think our retry handling never worked for Timeout Errors. The next beta will have a potential fix for this.

wow, very good to know, unfortunately the timeout "Maximum wait time for network" didn't work, I set it to 30 seconds, which is the maximum limit, and it didn't work, it keeps crashing.

pannal commented 2 days ago

You can try this, it might have fixed timeout error retry logic: script.plexmod.zip

(This already uses the new templating engine, so the first start will be slow, and, in that work in progress beta, every start will be slow once you enable DEBUG)

evertonmdz commented 2 days ago

You can try this, it might have fixed timeout error retry logic: script.plexmod.zip

(This already uses the new templating engine, so the first start will be slow, and, in that work in progress beta, every start will be slow once you enable DEBUG)

It didn't work, it still collapses after coming back from sleep mode, sometimes it comes back partially as was the case in the last log below, but if you try to navigate in some sections it goes into a loading loop like the photo in the post. But thank you for trying to help, as I said earlier, this doesn't happen on Android TV, only on Coreelec! Let's see if more people appear with this problem, a "temporary solution" is not to turn off the TV box. log-2024-07-05-13.05.04.zip log-2024-07-05-13.09.18.zip

pannal commented 2 days ago

Hmm, I don't see any Tracebacks/Errors in your latest logs anymore, regarding this issue.

pannal commented 2 days ago

With the latest version I've posted, can you exit PM4K, start it again, and then it works?

If so, I could try implementing a "Restart plugin after wakeup" option for "System->Action on Sleep event". Or simply a "Exit PM4K".

evertonmdz commented 2 days ago

With the latest version I've posted, can you exit PM4K, start it again, and then it works?

If so, I could try implementing a "Restart plugin after wakeup" option for "System->Action on Sleep event". Or simply a "Exit PM4K".

I understand, but here it keeps crashing lol, I think I'll use the TV box's Android TV for now, it doesn't have these problems and stuttering problem. I tried to click on exiting the addon after returning from sleep mode, it stayed on this screen and froze, it just keeps loading without stopping in a loop log-2024-07-05-13.57.03.zip 20240705_105558

pannal commented 2 days ago

OK wait, maybe I can circumvent this.

I'm seeing:

2024-07-05 10:55:11.027 T:1120  warning <general>: PLEX.download: Server unreachable at: https://192-168-1-4.c62f760bf6874b0ba9129a4a6f81c2df.plex.direct:32400
2024-07-05 10:55:11.027 T:1120  warning <general>: PLEX.download: HTTPSConnectionPool(host='192-168-1-4.c62f760bf6874b0ba9129a4a6f81c2df.plex.direct', port=32400): Max retries exceeded with url: / (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x7f4c18d3b0>: Failed to resolve '192-168-1-4.c62f760bf6874b0ba9129a4a6f81c2df.plex.direct' ([Errno -3] Temporary failure in name resolution)"))

from a different addon (I guess PKC) and

2024-07-05 10:55:11.299 T:1122     info <general>: PLEX.service: Server is online and ready

about 200ms afterwards.

I'll try and implement a "Action on Wake" setting, with the options: "None", "Restart PM4K" as well as "Wait for X seconds" where X is 5, 10, 15, ... .

From what I can gather, 1 should be enough, easily. Bear with me.

Edit: Oh, might have to be 15 seconds for your specific case.

evertonmdz commented 2 days ago

OK wait, maybe I can circumvent this.

I'm seeing:

2024-07-05 10:55:11.027 T:1120  warning <general>: PLEX.download: Server unreachable at: https://192-168-1-4.c62f760bf6874b0ba9129a4a6f81c2df.plex.direct:32400
2024-07-05 10:55:11.027 T:1120  warning <general>: PLEX.download: HTTPSConnectionPool(host='192-168-1-4.c62f760bf6874b0ba9129a4a6f81c2df.plex.direct', port=32400): Max retries exceeded with url: / (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x7f4c18d3b0>: Failed to resolve '192-168-1-4.c62f760bf6874b0ba9129a4a6f81c2df.plex.direct' ([Errno -3] Temporary failure in name resolution)"))

from a different addon (I guess PKC) and

2024-07-05 10:55:11.299 T:1122     info <general>: PLEX.service: Server is online and ready

about 200ms afterwards.

I'll try and implement a "Action on Wake" setting, with the options: "None", "Restart PM4K" as well as "Wait for X seconds" where X is 5, 10, 15, ... .

From what I can gather, 1 should be enough, easily. Bear with me.

Edit: Oh, might have to be 15 seconds for your specific case.

Yes, PKC doesn't show any errors because it runs connected to Kodi, I even tried to disable it, but it doesn't help PM4K. Yes yes, I understand, I'm not charging you anything hehe, especially because you don't have a CoreElec installation, there's no need to be in a hurry about this, because as I said, the TV box runs both Android TV and CoreElec, I only use CoreElec because it is lighter. But perhaps these implementations that you have made can work. I even tested its beta on AndroidTv too, these new implementations were really cool. Congratulations.

pannal commented 2 days ago

Try this please: script.plexmod.zip

There's a new setting under PM4K->Settings->System called "Action on Wake event". Please try setting this to 10, 15, 30 seconds and see whether this fixes the issue.

Yes, PKC doesn't show any errors

Ah I guess "PLEX.download" is a different addon. Edit: Hmm, "PLEX.service" seems to be PKC, though. It simply seems to recover better than we are.

evertonmdz commented 2 days ago

Try this please: script.plexmod.zip

There's a new setting under PM4K->Settings->System called "Action on Wake event". Please try setting this to 10, 15, 30 seconds and see whether this fixes the issue.

Yes, PKC doesn't show any errors

Ah I guess "PLEX.download" is a different addon. Edit: Hmm, "PLEX.service" seems to be PKC, though. It simply seems to recover better than we are.

Lol, congratulations on the quick solution, it was resolved with just a 5 second delay, as I use a network cable, so the connection is quick to resume. No more problems in suspend mode! I'll leave the log if you want to see how it went, but it's normal now! log-2024-07-05-15.09.19.zip

pannal commented 2 days ago

Awesome. I forgot to increase the theme version in that build, so your UI isn't up to date.

Please use this: script.plexmod.zip

pannal commented 2 days ago

Closing!

pannal commented 2 days ago

I'll make the five second wait a default for CoreELEC, I think.