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

Text editor loses connection when app sent to background then Reconnect fails #12138

Open
4 tasks done
qole opened this issue Nov 6, 2023 · 16 comments · May be fixed by nextcloud/text#5662
Open
4 tasks done

Text editor loses connection when app sent to background then Reconnect fails #12138

qole opened this issue Nov 6, 2023 · 16 comments · May be fixed by nextcloud/text#5662

Comments

@qole
Copy link

qole commented Nov 6, 2023

⚠️ Before posting ⚠️

  • This is a bug, not a question or an enhancement.
  • I've searched for similar issues and didn't find a duplicate.
  • I've written a clear and descriptive title for this issue, not just "Bug" or "Crash".
  • I agree to follow Nextcloud's Code of Conduct.

Steps to reproduce

In Nextcloud android app, create or open a text file, like "notes.md"
Go to another app, like the browser. Stay there a while (a minute or two?)
Return to Nextcloud app

Expected behaviour

The text file should be editable

Actual behaviour

The text file is not editable.
"Reconnect" button appears partly obscured by the toolbar
Pressing the "Reconnect" button doesn't work, only "File could not be loaded. Please check your internet connection"
Screenshot_20231105-175658_Nextcloud
Screenshot_20231105-175722_Nextcloud

Android version

9

Device brand and model

Samsung S8

Stock or custom OS?

Stock

Nextcloud android app version

3.26.0

Nextcloud server version

27.1.3

Using a reverse proxy?

No

Android logs

No response

Server error logs

No response

Additional information

I'm sorry that I cannot provide a log file, I don't have logcat installed

@qole qole added the bug label Nov 6, 2023
@joshtrichards joshtrichards changed the title Text editor loses connection when app sent to background Text editor loses connection when app sent to background then Reconnect fails Nov 17, 2023
@joshtrichards
Copy link
Member

Reproduced on a Pixel 7 (Android 13). Thanks for the report, @qole.

"Reconnect" button appears partly obscured by the toolbar
Pressing the "Reconnect" button doesn't work, only "File could not be loaded. Please check your internet connection"

I'm not sure much can be done about preventing the loss of the connection when moved to the background, but the Reconnect button being partly obscured and reconnect not functioning are definitely bugs.

Likely Text app (https://github.com/nextcloud/text) matters, but there may also be something going on in the Android client that brings one or the other out.

@qole
Copy link
Author

qole commented Nov 19, 2023

I think both bugs are symptoms of the same problem, the text editor can't reconnect on being re-foregrounded. I suspect the developers didn't intend the "Reconnect" button to appear at all, it should simply reconnect silently, and only escalate to a reconnect button when it can't connect. I suspect some essential connection info (credentials? certificate?) is being lost when the app is backgrounded. It might be relying on a cache that is not maintained when backgrounded? I'm speculating...

@joshtrichards
Copy link
Member

Hmm. Might be related to #11800.

@cfbowin
Copy link

cfbowin commented Dec 22, 2023

I have the same issue, opening any .md file within the Nextcloud Andoid app results in this error if it is sent to the background and then opened again a short while later.

Same issue happens in the Notes app but only if the rich editing mode is enabled. If the simple editing mode is enabled when the app is sent to the background, no conneciton issue arises.

This issue has not been experienced with the desktop browser.

Only current solution I have found is to back out from editing the file and then open it again, this works in both the Nextcloud Android and Notes app.

Android: 12
Nextcloud Server: 27.1.5
Nextcloud Android: 3.26.0
Notes Android: 4.1.0

@dbolton
Copy link

dbolton commented Feb 1, 2024

Maybe fixed by nextcloud/text#5126 ?

@qole
Copy link
Author

qole commented Feb 2, 2024

I just installed the Android development version (20240202) and the bug is still present. It says that text#5126 has been merged so I assume that it's in this build? Is there a better way to test it?

@joshtrichards
Copy link
Member

@qole The direct editor is a server-side component so it'll be dependent on Server version and Text app version.

@XueSheng-GIT
Copy link

I'm on NC 28.0.2 and the issue is not fixed.

@nicofrand
Copy link

nicofrand commented Feb 5, 2024

I have the same issue, with NC 28.0.2 but I am afraid the logcat does not help much:

02-05 16:05:42.483  4951 12520 D FileContentProvider: applied batch in provider com.owncloud.android.providers.FileContentProvider@9e3d0f7
02-05 16:05:42.483  4951 12520 D RefreshFolderOperation: Send broadcast com.owncloud.android.operations.RefreshFolderOperation.EVENT_SINGLE_FOLDER_SHARES_SYNCED
02-05 16:05:42.485  4951  4951 D DecorView[]: onWindowFocusChanged hasWindowFocus false
02-05 16:05:42.513  4951  4951 D DecorView[]: onWindowFocusChanged hasWindowFocus true
02-05 16:05:42.956  4951  4951 D FileDisplayActivity: onStop() ending
02-05 16:05:42.957  4951  4951 V FileDisplayActivity: onSaveInstanceState() start
02-05 16:05:42.957  4951  4951 D FileDisplayActivity: onSaveInstanceState(Bundle) starting
02-05 16:05:42.958  4951  4951 D ExtendedListFragment: onSaveInstanceState()
02-05 16:05:42.959  4951  4951 V FileDisplayActivity: onSaveInstanceState() end
02-05 16:05:44.488  4951  5111 W chromium: [WARNING:display_webview.cc(32)] WebView overlays are enabled!
02-05 16:06:12.769  4951  4951 D TextEditorWebView: onPause() ending
02-05 16:06:12.825  4951  4951 D TextEditorWebView: onStop() ending
02-05 16:06:12.827  4951  4951 D TextEditorWebView: onSaveInstanceState(Bundle) starting
02-05 16:06:12.831  4951  4951 D DecorView[]: onWindowFocusChanged hasWindowFocus false
02-05 16:06:12.858  4951  4963 W System  : A resource failed to call close. 
02-05 16:06:12.858  4951  4963 W System  : A resource failed to call close. 
02-05 16:06:12.858  4951  4963 W System  : A resource failed to call close. 
02-05 16:06:12.858  4951  4963 W System  : A resource failed to call close. 
02-05 16:06:12.858  4951  4963 W System  : A resource failed to call close. 
02-05 16:06:12.858  4951  4963 W System  : A resource failed to call close. 
02-05 16:06:12.859  4951  4963 W System  : A resource failed to call close. 
02-05 16:06:12.859  4951  4963 W System  : A resource failed to call close. 
02-05 16:06:12.859  4951  4963 W System  : A resource failed to call close. 
02-05 16:06:12.859  4951  4963 W System  : A resource failed to call close. 
02-05 16:06:12.859  4951  4963 W System  : A resource failed to call close. 
02-05 16:06:12.859  4951  4963 W System  : A resource failed to call close. 
02-05 16:06:12.859  4951  4963 W System  : A resource failed to call close. 
02-05 16:06:12.859  4951  4963 W System  : A resource failed to call close. 
02-05 16:06:12.860  4951  4963 W System  : A resource failed to call close. 
02-05 16:06:12.860  4951  4963 W System  : A resource failed to call close. 
02-05 16:06:12.860  4951  4963 W System  : A resource failed to call close. 
02-05 16:06:12.860  4951  4963 W System  : A resource failed to call close. 
02-05 16:06:12.860  4951  4963 W System  : A resource failed to call close. 
02-05 16:06:12.861  4951  4963 W System  : A resource failed to call close. 
02-05 16:06:14.028  4951  4951 V BaseActivity: onRestart() start
02-05 16:06:14.030  4951  4951 D TextEditorWebView: onStart() starting
02-05 16:06:14.035  4951  4951 D TextEditorWebView: onResume() starting
02-05 16:06:14.074  4951 12605 D ExternalLinks: links disabled
02-05 16:06:14.076  4951  4966 D AppScoutStateMachine: 4951-ScoutStateMachinecreated
02-05 16:06:14.683  4951  4951 D DecorView[]: onWindowFocusChanged hasWindowFocus true
02-05 16:06:16.352  4951  4951 D TextEditorWebView: onPause() ending
02-05 16:06:16.368  4951  4951 D DecorView[]: onWindowFocusChanged hasWindowFocus false
02-05 16:06:16.695  4951  4951 D TextEditorWebView: onStop() ending
02-05 16:06:16.696  4951  4951 D TextEditorWebView: onSaveInstanceState(Bundle) starting
02-05 16:08:55.819  4951  6371 D AppScoutStateMachine: 4951-ScoutStateMachinecreated
02-05 16:08:55.821  4951  4951 V BaseActivity: onRestart() start
02-05 16:08:55.827  4951  4951 D TextEditorWebView: onStart() starting
02-05 16:08:55.831  4951  4951 D TextEditorWebView: onResume() starting
02-05 16:08:55.839  4951 12868 D ExternalLinks: links disabled
02-05 16:08:55.867  4951  5111 W chromium: [WARNING:display_webview.cc(32)] WebView overlays are enabled!
02-05 16:08:55.916  4951  4951 D DecorView[]: onWindowFocusChanged hasWindowFocus true

At 02-05 16:06:16.696 I switched to my browser, then let the phone idle for some time until 02-05 16:08:55.819 when I went back to the Nextcloud app. The reconnect button was there, I clicked it several times without visible effect, nor logs produced in logcat.

I am using the latest F-Droid version of the Nextcloud android application by the way.

@nicofrand
Copy link

nicofrand commented Feb 16, 2024

Hi,

is there any way I can help (given that I am not an android dev nor know the app's code)?

I can access my phone (unrooted) through adb, and my nextcloud's server logs.

This issue makes it hard to use the Notes app in a reliable way (for ex. when constantly switching from a shopping list in Notes for ex. to a supermarket's app)?

Nextcloud dev also has the issue btw.

@nicofrand
Copy link

nicofrand commented Mar 1, 2024

I tried reading the server logs when the issue happens and here is what I gathered:

0.0.0.0 - - [01/Mar/2024:08:27:46 +0000] "POST /apps/text/session/39083/sync HTTP/2.0" 200 568 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.29.0 Alpha1"                                                                            
0.0.0.0 - - [01/Mar/2024:08:27:47 +0000] "POST /apps/text/session/39083/push HTTP/2.0" 200 2 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.29.0 Alpha1"                                                                              
0.0.0.0 - - [01/Mar/2024:08:27:51 +0000] "POST /apps/text/session/39083/sync HTTP/2.0" 200 568 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.29.0 Alpha1"                                                                            
0.0.0.0 - - [01/Mar/2024:08:27:56 +0000] "POST /apps/text/session/39083/sync HTTP/2.0" 200 568 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.29.0 Alpha1"                                                                            
0.0.0.0 - - [01/Mar/2024:08:28:01 +0000] "POST /apps/text/session/39083/sync HTTP/2.0" 200 569 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.29.0 Alpha1"                                                                            
0.0.0.0 - - [01/Mar/2024:08:28:02 +0000] "POST /apps/text/session/39083/push HTTP/2.0" 200 2 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.29.0 Alpha1"                                                                              
0.0.0.0 - - [01/Mar/2024:08:28:06 +0000] "POST /apps/text/session/39083/sync HTTP/2.0" 200 569 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.29.0 Alpha1"
0.0.0.0 - - [01/Mar/2024:08:28:11 +0000] "POST /apps/text/session/39083/sync HTTP/2.0" 200 569 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.29.0 Alpha1"
0.0.0.0 - - [01/Mar/2024:08:28:17 +0000] "POST /apps/text/session/39083/sync HTTP/2.0" 200 569 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.29.0 Alpha1"
0.0.0.0 - - [01/Mar/2024:08:28:17 +0000] "POST /apps/text/session/39083/push HTTP/2.0" 200 2 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.29.0 Alpha1"
0.0.0.0 - - [01/Mar/2024:08:28:22 +0000] "POST /apps/text/session/39083/sync HTTP/2.0" 200 570 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.29.0 Alpha1"
0.0.0.0 - - [01/Mar/2024:08:28:27 +0000] "POST /apps/text/session/39083/sync HTTP/2.0" 200 570 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.29.0 Alpha1"
0.0.0.0 - - [01/Mar/2024:08:28:32 +0000] "POST /apps/text/session/39083/push HTTP/2.0" 200 2 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.29.0 Alpha1"
0.0.0.0 - - [01/Mar/2024:08:28:32 +0000] "POST /apps/text/session/39083/sync HTTP/2.0" 200 568 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.29.0 Alpha1"
0.0.0.0 - - [01/Mar/2024:08:28:37 +0000] "POST /apps/text/session/39083/sync HTTP/2.0" 200 568 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.29.0 Alpha1"
0.0.0.0 - - [01/Mar/2024:08:28:42 +0000] "POST /apps/text/session/39083/sync HTTP/2.0" 200 568 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.29.0 Alpha1"
0.0.0.0 - - [01/Mar/2024:08:28:47 +0000] "POST /apps/text/session/39083/push HTTP/2.0" 200 2 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.29.0 Alpha1"
0.0.0.0 - - [01/Mar/2024:08:28:47 +0000] "POST /apps/text/session/39083/sync HTTP/2.0" 200 568 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.29.0 Alpha1"
0.0.0.0 - - [01/Mar/2024:08:28:52 +0000] "POST /apps/text/session/39083/sync HTTP/2.0" 200 568 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.29.0 Alpha1"
0.0.0.0 - - [01/Mar/2024:08:28:57 +0000] "POST /apps/text/session/39083/sync HTTP/2.0" 200 568 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.29.0 Alpha1"
0.0.0.0 - - [01/Mar/2024:08:29:02 +0000] "POST /apps/text/session/39083/push HTTP/2.0" 200 2 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.29.0 Alpha1"
0.0.0.0 - - [01/Mar/2024:08:29:02 +0000] "POST /apps/text/session/39083/sync HTTP/2.0" 200 568 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.29.0 Alpha1"
0.0.0.0 - - [01/Mar/2024:08:29:18 +0000] "POST /apps/text/session/39083/push HTTP/2.0" 200 2 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.29.0 Alpha1"
0.0.0.0 - - [01/Mar/2024:08:29:33 +0000] "POST /apps/text/session/39083/push HTTP/2.0" 200 2 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.29.0 Alpha1"
0.0.0.0 - - [01/Mar/2024:08:29:35 +0000] "POST /apps/text/session/39083/close HTTP/2.0" 200 2 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.29.0 Alpha1"
0.0.0.0 - - [01/Mar/2024:08:29:36 +0000] "POST /apps/text/attachments HTTP/2.0" 403 0 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.29.0 Alpha1"
0.0.0.0 - - [01/Mar/2024:08:29:37 +0000] "POST /apps/text/session/39083/sync HTTP/2.0" 403 0 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.29.0 Alpha1"
0.0.0.0 - - [01/Mar/2024:08:29:37 +0000] "POST /apps/text/session/39083/push HTTP/2.0" 403 0 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.29.0 Alpha1"
0.0.0.0 - - [01/Mar/2024:08:29:48 +0000] "POST /apps/text/session/39083/push HTTP/2.0" 403 0 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.29.0 Alpha1"
0.0.0.0 - nicofrand [01/Mar/2024:08:29:56 +0000] "GET /ocs/v2.php/cloud/capabilities?format=json HTTP/1.1" 200 2467 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.29.0 Alpha1"
0.0.0.0 - - [01/Mar/2024:08:30:02 +0000] "POST /apps/text/session/39083/close HTTP/2.0" 200 2 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.29.0 Alpha1"
0.0.0.0 - - [01/Mar/2024:08:30:02 +0000] "POST /apps/text/attachments HTTP/2.0" 403 0 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.29.0 Alpha1"
0.0.0.0 - - [01/Mar/2024:08:30:02 +0000] "POST /apps/text/session/39083/sync HTTP/2.0" 403 0 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.29.0 Alpha1"
0.0.0.0 - - [01/Mar/2024:08:30:02 +0000] "POST /apps/text/session/39083/push HTTP/2.0" 403 0 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.29.0 Alpha1"
0.0.0.0 - - [01/Mar/2024:08:30:20 +0000] "POST /apps/text/session/39083/push HTTP/2.0" 403 0 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.29.0 Alpha1"
0.0.0.0 - - [01/Mar/2024:08:30:35 +0000] "POST /apps/text/session/39083/push HTTP/2.0" 403 0 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.29.0 Alpha1"
0.0.0.0 - - [01/Mar/2024:08:30:35 +0000] "POST /apps/text/session/39083/close HTTP/2.0" 200 2 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.29.0 Alpha1"
  • /sync is called every 5 seconds. But when put in background, /sync is called with an interval greater than 5 seconds (maybe the webview throttles the calls).
  • /push is called every 15 seconds
  • When /push is called twice without a /sync happening between the two, /close seems to be called and then every following request receives a 403 error.

When clicking on the Reconnect button a /close request is sent to the same session, which returns a 200 error, but then every other request (/attachments, /sync, /push`) is made on the same session number (which is closed).

I then checked with the webview browser directly:

0.0.0.0 - - [01/Mar/2024:08:50:39 +0000] "PUT /apps/text/session/55712/create HTTP/2.0" 200 528 "-" "Mozilla/5.0 (Linux; Android 12; sdk_gphone64_x86_64 Build/SE1A.211212.001.B1; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/
4.0 Chrome/121.0.6167.178 Mobile Safari/537.36"
0.0.0.0 - - [01/Mar/2024:08:50:39 +0000] "POST /apps/text/attachments HTTP/2.0" 200 2 "-" "Mozilla/5.0 (Linux; Android 12; sdk_gphone64_x86_64 Build/SE1A.211212.001.B1; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/121.0.6167.178 Mobile Safari/537.36"
0.0.0.0 - - [01/Mar/2024:08:50:40 +0000] "POST /apps/text/session/55712/sync HTTP/2.0" 200 431 "-" "Mozilla/5.0 (Linux; Android 12; sdk_gphone64_x86_64 Build/SE1A.211212.001.B1; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/121.0.6167.178 Mobile Safari/537.36"
0.0.0.0 - - [01/Mar/2024:08:50:40 +0000] "POST /apps/text/session/55712/push HTTP/2.0" 200 360 "-" "Mozilla/5.0 (Linux; Android 12; sdk_gphone64_x86_64 Build/SE1A.211212.001.B1; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/121.0.6167.178 Mobile Safari/537.36"
0.0.0.0 - - [01/Mar/2024:08:50:40 +0000] "POST /apps/text/session/55712/push HTTP/2.0" 200 2 "-" "Mozilla/5.0 (Linux; Android 12; sdk_gphone64_x86_64 Build/SE1A.211212.001.B1; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/121.0.6167.178 Mobile Safari/537.36"
0.0.0.0 - - [01/Mar/2024:08:50:45 +0000] "POST /apps/text/session/55712/sync HTTP/2.0" 200 585 "-" "Mozilla/5.0 (Linux; Android 12; sdk_gphone64_x86_64 Build/SE1A.211212.001.B1; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/121.0.6167.178 Mobile Safari/537.36"
0.0.0.0 - - [01/Mar/2024:08:50:48 +0000] "GET /apps/files/api/v1/stats HTTP/2.0" 200 202 "-" "Mozilla/5.0 (Linux; Android 12; sdk_gphone64_x86_64 Build/SE1A.211212.001.B1; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/121.0.6167.178 Mobile Safari/537.36"
0.0.0.0 - - [01/Mar/2024:08:50:50 +0000] "POST /apps/text/session/55712/sync HTTP/2.0" 200 585 "-" "Mozilla/5.0 (Linux; Android 12; sdk_gphone64_x86_64 Build/SE1A.211212.001.B1; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/121.0.6167.178 Mobile Safari/537.36"
0.0.0.0 - - [01/Mar/2024:08:50:55 +0000] "POST /apps/text/session/55712/sync HTTP/2.0" 200 585 "-" "Mozilla/5.0 (Linux; Android 12; sdk_gphone64_x86_64 Build/SE1A.211212.001.B1; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/121.0.6167.178 Mobile Safari/537.36"
0.0.0.0 - - [01/Mar/2024:08:50:58 +0000] "POST /apps/text/session/55712/push HTTP/2.0" 200 2 "-" "Mozilla/5.0 (Linux; Android 12; sdk_gphone64_x86_64 Build/SE1A.211212.001.B1; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/121.0.6167.178 Mobile Safari/537.36"
0.0.0.0 - - [01/Mar/2024:08:51:00 +0000] "POST /apps/text/session/55712/sync HTTP/2.0" 200 585 "-" "Mozilla/5.0 (Linux; Android 12; sdk_gphone64_x86_64 Build/SE1A.211212.001.B1; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/121.0.6167.178 Mobile Safari/537.36"
0.0.0.0 - - [01/Mar/2024:08:51:05 +0000] "POST /apps/text/session/55712/sync HTTP/2.0" 200 585 "-" "Mozilla/5.0 (Linux; Android 12; sdk_gphone64_x86_64 Build/SE1A.211212.001.B1; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/121.0.6167.178 Mobile Safari/537.36"
0.0.0.0 - - [01/Mar/2024:08:51:14 +0000] "POST /apps/text/session/55712/push HTTP/2.0" 200 2 "-" "Mozilla/5.0 (Linux; Android 12; sdk_gphone64_x86_64 Build/SE1A.211212.001.B1; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/121.0.6167.178 Mobile Safari/537.36"
0.0.0.0 - - [01/Mar/2024:08:51:32 +0000] "POST /apps/text/session/55712/push HTTP/2.0" 200 2 "-" "Mozilla/5.0 (Linux; Android 12; sdk_gphone64_x86_64 Build/SE1A.211212.001.B1; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/121.0.6167.178 Mobile Safari/537.36"
0.0.0.0 - - [01/Mar/2024:08:51:37 +0000] "POST /apps/text/session/55712/close HTTP/2.0" 200 2 "-" "Mozilla/5.0 (Linux; Android 12; sdk_gphone64_x86_64 Build/SE1A.211212.001.B1; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/121.0.6167.178 Mobile Safari/537.36"
0.0.0.0 - - [01/Mar/2024:08:51:38 +0000] "PUT /apps/text/session/55712/create HTTP/2.0" 200 528 "-" "Mozilla/5.0 (Linux; Android 12; sdk_gphone64_x86_64 Build/SE1A.211212.001.B1; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/121.0.6167.178 Mobile Safari/537.36"
0.0.0.0 - - [01/Mar/2024:08:51:38 +0000] "POST /apps/text/attachments HTTP/2.0" 200 2 "-" "Mozilla/5.0 (Linux; Android 12; sdk_gphone64_x86_64 Build/SE1A.211212.001.B1; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/121.0.6167.178 Mobile Safari/537.36"
0.0.0.0 - - [01/Mar/2024:08:51:39 +0000] "POST /apps/text/session/55712/push HTTP/2.0" 200 360 "-" "Mozilla/5.0 (Linux; Android 12; sdk_gphone64_x86_64 Build/SE1A.211212.001.B1; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/121.0.6167.178 Mobile Safari/537.36"
0.0.0.0 - - [01/Mar/2024:08:51:39 +0000] "POST /apps/text/session/55712/sync HTTP/2.0" 200 585 "-" "Mozilla/5.0 (Linux; Android 12; sdk_gphone64_x86_64 Build/SE1A.211212.001.B1; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/121.0.6167.178 Mobile Safari/537.36"
0.0.0.0 - - [01/Mar/2024:08:51:45 +0000] "POST /apps/text/session/55712/sync HTTP/2.0" 200 585 "-" "Mozilla/5.0 (Linux; Android 12; sdk_gphone64_x86_64 Build/SE1A.211212.001.B1; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/121.0.6167.178 Mobile Safari/537.36"
0.0.0.0 - - [01/Mar/2024:08:51:47 +0000] "POST /apps/text/session/55712/push HTTP/2.0" 200 2 "-" "Mozilla/5.0 (Linux; Android 12; sdk_gphone64_x86_64 Build/SE1A.211212.001.B1; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/121.0.6167.178 Mobile Safari/537.36"
0.0.0.0 - - [01/Mar/2024:08:51:48 +0000] "GET /apps/files/api/v1/stats HTTP/2.0" 200 202 "-"

I notice the same behaviour: 2 consecutive /push then a /close request happens. Some /stats or /save (weird, I did not edit anything) requests might happen too.

BUT a /create is then made on the same session (and no Reconnect buttons appeared)!

TL;DR:

  1. On a mobile browser once a session is closed, a new one (same number id though) is created through a /create request.
  2. Within the android app the /create request is never called (even when clicking on "Reconnect").

The /create endpoint is called here: https://github.com/nextcloud/text/blob/main/src/services/SessionApi.js#L42 from here only: https://github.com/nextcloud/text/blob/main/src/services/SyncService.js#L95.

I added a console.log("Initial session:", JSON.stringify(initialSession)) in my editor.js and then in the nextcloud app this code to access the webview's console messages: https://developer.android.com/develop/ui/views/layout/webapps/debugging#java.

  1. On my dekstop's Firefox (did not manage to get the console messages from the webview itself) initialSession is always null .
  2. Within the android app initialSession is always non-null

Here are the console logs from within the apps:

2024-03-01 10:42:01.011 32363-32363 MyApplication           com.nextcloud.client                 D  Error with Feature-Policy header: Unrecognized feature: 'payment'. -- From line 0 of 
2024-03-01 10:42:01.012 32363-32363 MyApplication           com.nextcloud.client                 D  Error with Permissions-Policy header: Origin trial controlled feature not enabled: 'interest-cohort'. -- From line 0 of 
2024-03-01 10:42:02.013 32363-32363 MyApplication           com.nextcloud.client                 D  JQMIGRATE: Migrate is installed, version 3.4.1 -- From line 2 of https://domain.tld/dist/core-main.js?v=6d0ffef0-0
2024-03-01 10:42:02.133 32363-32363 MyApplication           com.nextcloud.client                 D  session heartbeat polling started -- From line 2 of https://domain.tld/dist/core-main.js?v=6d0ffef0-0
2024-03-01 10:42:03.520 32363-32363 MyApplication           com.nextcloud.client                 D  Initial session: {"document":{"id":81789,"lastSavedVersion":9972,"lastSavedVersionTime":1709039980,"baseVersionEtag":"f5514db8cfb67704912d0a1d445b2323","initialVersion":0},"session":{"id":1384,"userId":"nicofrand","token":"TOKEN","color":"#b6469d","lastAwarenessMessage":"","lastContact":1709286110,"guestName":null,"documentId":81789,"displayName":"MYNAME"},"readOnly":false,"content":null,"documentState":"SOMELONGHASH
2024-03-01 10:42:03.637 32363-32363 MyApplication           com.nextcloud.client                 D  Error: Could not find initial state textprocessing of text -- From line 2 of https://domain.tld/apps/text/js/text-text.js?v=6d0ffef0-0
2024-03-01 10:42:46.593 32363-32363 MyApplication           com.nextcloud.client                 D  Initial session: {"document":{"id":81789,"lastSavedVersion":9972,"lastSavedVersionTime":1709039980,"baseVersionEtag":"f5514db8cfb67704912d0a1d445b2323","initialVersion":0},"session":{"id":1384,"userId":"nicofrand","token":"TOKEN","color":"#b6469d","lastAwarenessMessage":"","lastContact":1709286110,"guestName":null,"documentId":81789,"displayName":"MYNAME"},"readOnly":false,"content":null,"documentState":"SOMELONGHASH
2024-03-01 10:42:46.657 32363-32363 MyApplication           com.nextcloud.client                 D  Uncaught (in promise) AxiosError: Request failed with status code 403 -- From line 2 of https://domain.tld/apps/text/js/text-text.js?v=6d0ffef0-0
2024-03-01 10:42:47.698 32363-32363 MyApplication           com.nextcloud.client                 D  [ERROR] text: failed to write to document - not allowed [object Object] -- From line 2 of https://domain.tld/apps/text/js/vendors-node_modules_path-normalize_lib_index_js-node_modules_proxy-polyfill_src_index_js-nod-598231.js?v=0cbed9c9d6cdaa285205
2024-03-01 10:42:47.699 32363-32363 MyApplication           com.nextcloud.client                 D  [ERROR] text: Unexpected Error "Failed to apply steps. Retry!" [object Object] -- From line 2 of https://domain.tld/apps/text/js/vendors-node_modules_path-normalize_lib_index_js-node_modules_proxy-polyfill_src_index_js-nod-598231.js?v=0cbed9c9d6cdaa285205
2024-03-01 10:42:58.687 32363-32363 MyApplication           com.nextcloud.client                 D  [ERROR] text: failed to write to document - not allowed [object Object] -- From line

@nicofrand
Copy link

Maybe related to nextcloud/text#4480?

@nicofrand
Copy link

nicofrand commented Mar 27, 2024

Spoke with @juliushaertl about it and here is a sum-up on how to tackle it:

I'll now see how to properly set a Text development environment to do that and then edit the Android app too.

@nicofrand
Copy link

For the Text app I added some events requesting the Nextcloud app to reload everything: https://github.com/nicofrand/nextcloud-text/commits/fixReconnect/.

Withing the Android app I caught the event but somehow the HTTP request always returns a 404: https://github.com/nicofrand/nextcloud-android/commits/reloadWebView

@juliushaertl
Copy link
Member

As mentioned in chat, the urls are one time access only, so the android app would need to request a new url from the server through the direct editing OCS API, but I'm not familiar enough with the android code base to tell how to do that.

@pschichtel
Copy link

For me this is happening even if I immediately unlock the device after it got locked, if I started "editing" (touching it once to open the keyboard is enough) before it locked. I can confirm the 403 responses on push, sync and attachments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants