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

「プッシュ通知の更新をしました」という通知が点滅し続ける #8906

Closed
TranslucentFoxHuman opened this issue Jun 29, 2022 · 22 comments
Labels
⚠️bug? This might be a bug 🔥high priority packages/sw and PWA ServiceWorker and PWA related issue/PR

Comments

@TranslucentFoxHuman
Copy link

💡 Summary

僕はMisskey 12.111.1のインスタンスを運用しています。
ブラウザでMisskeyを開くと、「プッシュ通知の更新をしました」という通知が、Misskeyを開いている間高速で点滅し続け、CPUに負荷をかけ、画面の一部を邪魔します。

🥰 Expected Behavior

このような通知は表示されるべきではありません。

🤬 Actual Behavior

高速に通知が表示され続けます。

📝 Steps to Reproduce

  1. プッシュ通知を有効化します。
  2. ブラウザでMisskeyを開きます。

📌 Environment

Misskey version: 12.111.1
Your OS (クライアント): Ubuntu 20.04
Your OS (サーバ): Debian 11
Your browser: Firefox 101.0.1

@TranslucentFoxHuman TranslucentFoxHuman added the ⚠️bug? This might be a bug label Jun 29, 2022
@syuilo syuilo added the packages/frontend Client side specific issue/PR label Jun 29, 2022
@rinsuki rinsuki removed the packages/frontend Client side specific issue/PR label Jun 29, 2022
@rinsuki
Copy link
Contributor

rinsuki commented Jun 29, 2022

related: #7667

やっぱ既読消すのやめたほうがいいんじゃないかなあ

@rinsuki rinsuki closed this as completed Jun 29, 2022
@rinsuki rinsuki reopened this Jun 29, 2022
@rinsuki
Copy link
Contributor

rinsuki commented Jun 29, 2022

操作ミス

@rinsuki rinsuki closed this as completed Jun 29, 2022
@rinsuki rinsuki reopened this Jun 29, 2022
@rinsuki
Copy link
Contributor

rinsuki commented Jun 29, 2022

なんか Command + Enter 押すと close with comment になってしまう

@syuilo
Copy link
Member

syuilo commented Jun 30, 2022

readNotifications とか readAllNotifications あたりの処理消せば解決する?

@tamaina
Copy link
Member

tamaina commented Jul 5, 2022

Related: #8824

@tamaina
Copy link
Member

tamaina commented Jul 5, 2022

@TranslucentFoxHuman 「Misskeyをブラウザで開いている間」というのは、Misskeyを開いている間ずっと起きますか?それともMisskeyを開いた直後だけそうなりますか?
(後者は想定された動作ですが、前者は想定されていない動作です)

@TranslucentFoxHuman
Copy link
Author

このイシューを投稿した当時は、Misskeyを表示している間は常に表示され続けました。
現在は、開いた直後に発生し、その後は落ち付きます。

この間、Misskeyの更新やFirefoxの更新などの一切の更新はしていません。

@tamaina
Copy link
Member

tamaina commented Jul 5, 2022

@TranslucentFoxHuman SubwayTooterはご利用ですか?SubwayTooterのバグが原因であると考えます。

@TranslucentFoxHuman
Copy link
Author

SubwayTooterは使用しています。SubwayTooterでも同様に通知が点滅する現象がありました。

SubwayTooterのバグが、別なクライアントでの動作にも影響を及ぼすのですか?

@tamaina
Copy link
Member

tamaina commented Jul 5, 2022

Yes. See #8835 and tateisu/SubwayTooter#191.

Duplicate of #8824

@tamaina tamaina closed this as not planned Won't fix, can't repro, duplicate, stale Jul 5, 2022
@TranslucentFoxHuman
Copy link
Author

ありがとうございます。
確かに、Subway Tooterを起動すると、デスクトップでその通知が点滅することを確認しました。
今は、自分が使用しているSubway Tooterが更新され、そのバグが解消されるまでSubway Tooter上で自Misskeyからログアウトしようと思います。

ありがとうございました。

@tateisu
Copy link

tateisu commented Jul 7, 2022

これは誰かが収集したSTのADBのログです。
https://bcome.nl/logcat3.txt

$ grep "PUSH_MESSAGING" logcat3.txt  |wc -l
11
$ grep https://borg.social/api/i/notifications logcat3.txt |wc -l
11

Misskeyサーバは WebPush メッセージをSTのアプリサーバに大量に送っていませんか? アプリサーバはFCM経由でそれをSTに伝えました。STはその数だけサーバにAPIリクエストを行いました。

@tateisu
Copy link

tateisu commented Jul 7, 2022

実際にクリアした未読がある(SQL的にはupdateの戻り値 >0である) 場合に未読クリアのWebPushを送るべきではないでしょうか。

@rinsuki
Copy link
Contributor

rinsuki commented Jul 7, 2022

っぽい

// Mark all as read
if (notifications.length > 0 && ps.markAsRead) {
readNotification(user.id, notifications.map(x => x.id));
}

export async function readNotification(
userId: User['id'],
notificationIds: Notification['id'][]
) {
if (notificationIds.length === 0) return;
// Update documents
await Notifications.update({
id: In(notificationIds),
isRead: false,
}, {
isRead: true,
});
if (!await Users.getHasUnreadNotification(userId)) return postReadAllNotifications(userId);
else return postReadNotifications(userId, notificationIds);
}

@tateisu
Copy link

tateisu commented Jul 7, 2022

根本的には、

  • 「通知APIにアクセスがあると未読クリアする」は
  • 「バックグラウンドで動く何かが通知APIにアクセスすることを想定していない」ので
  • 「クライアントはバックグラウンドで通知APIを呼び出すべきではない」となり

Pull通知チェックをベースとして追加でPush対応したSTが4.9.3で通知チェックをデフォルト無効にしたのは正解、となります。仕方ないね。

@rinsuki
Copy link
Contributor

rinsuki commented Jul 7, 2022

「バックグラウンドで動く何かが通知APIにアクセスすることを想定していない」ので

というよりかは markAsRead がデフォルトで true なのでユーザーが明示的にリクエストしていない場合は markAsRead に false を指定するべきという話そう (それならデフォルト値ないほうが良い気もするけど破壊的変更すぎるか)

@tateisu
Copy link

tateisu commented Jul 7, 2022

未読クリアが後から追加されたのならmarkAsRead はデフォルトfalseであるべきでは…? と思いますが、
とりあえずST的には markAsRead (Default:true )をfalse にして呼び出しますか…

@rinsuki
Copy link
Contributor

rinsuki commented Jul 7, 2022

既読付ける副作用は最初からデフォルトでONだけど https://github.com/misskey-dev/misskey/blame/2a9cba25a89b5cf2394a22696ee0fb67140076a9/src/api/endpoints/i/notifications.js#L24-L28 、これまで未読フラグがあんまり気にされていなかったので今まで誰も気づいていなかっただけっぽい (それはそれとしてread系のAPIでデフォルトで副作用が付いてくるのはちょっと…という)

@tateisu
Copy link

tateisu commented Jul 8, 2022

markAsRead:falseを追加した ST 4.9.4を作ってテストしてもらいましたが、まだプッシュメッセージが頻出するようでした。

  • 彼がそのアカウントを登録したSTは1端末だけだそうです。なので他の古いSTが影響しているということはありません。
  • WebUIを開いていたそうですが、それが影響するのかどうかは私には分かりません。

上のコメントで指摘されたように、実際に未読を更新した件数が0でもプッシュメッセージを送るのは、Misskeyのバグだと思います。修正していただきたいです。

@acid-chicken
Copy link
Member

(それはそれとしてread系のAPIでデフォルトで副作用が付いてくるのはちょっと…という)

文字通り (get ではなく) read だからでは

@tamaina
Copy link
Member

tamaina commented Nov 18, 2022

Has this been resolved? @TranslucentFoxHuman

@tamaina tamaina added the packages/sw and PWA ServiceWorker and PWA related issue/PR label Nov 18, 2022
@TranslucentFoxHuman
Copy link
Author

今、Subway Tooterで再度ログインしました。問題は今の所起きていないように見えます。
しばらく様子を見てみます。

@tamaina tamaina closed this as completed Apr 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚠️bug? This might be a bug 🔥high priority packages/sw and PWA ServiceWorker and PWA related issue/PR
Projects
None yet
Development

No branches or pull requests

6 participants