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

Improve further websocket efficiency #3394

Open
chibenwa opened this issue Jan 4, 2025 · 4 comments
Open

Improve further websocket efficiency #3394

chibenwa opened this issue Jan 4, 2025 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@chibenwa
Copy link
Member

chibenwa commented Jan 4, 2025

Description

GIVEN I update an email

{
    "sessionState": "2c9f1b12-b35a-43e6-9af2-0106fb53a943",
    "methodResponses": [
        [
            "Email/set",
            {
                "accountId": "50fb9073ba109901291988b0d78e8a602a6fcd96fbde033eb46ca308779f8fac",
                "oldState": "48d362c0-cae1-11ef-96a4-670e87cb73da",
                "newState": "765e7950-cae1-11ef-96a4-670e87cb73da",
                "updated": {
                    "32adf2d0-caa5-11ef-bec7-910f43596509": null
                }
            },
            "c0"
        ]
    ]
}

When tmail frontend receives the corresponding websocket notification it triggers a resynch for the very same state:

{
    "sessionState": "2c9f1b12-b35a-43e6-9af2-0106fb53a943",
    "methodResponses": [
        [
            "Email/changes",
            {
                "accountId": "50fb9073ba109901291988b0d78e8a602a6fcd96fbde033eb46ca308779f8fac",
                "oldState": "48d362c0-cae1-11ef-96a4-670e87cb73da",
                "newState": "765e7950-cae1-11ef-96a4-670e87cb73da",
                "hasMoreChanges": false,
                "created": [],
                "updated": [
                    "32adf2d0-caa5-11ef-bec7-910f43596509"
                ],
                "destroyed": []
            },
            "c0"
        ],
        [
            "Email/get",
            {
                "accountId": "50fb9073ba109901291988b0d78e8a602a6fcd96fbde033eb46ca308779f8fac",
                "state": "765e7950-cae1-11ef-96a4-670e87cb73da",
                "list": [
                    {
                        "id": "32adf2d0-caa5-11ef-bec7-910f43596509",
                        "keywords": {},
                        "mailboxIds": {
                            "679397f0-edde-11ea-b4a0-bbb288e57c64": true
                        }
                    }
                ],
                "notFound": []
            },
            "c1"
        ],
        [
            "Email/get",
            {
                "accountId": "50fb9073ba109901291988b0d78e8a602a6fcd96fbde033eb46ca308779f8fac",
                "state": "765e7950-cae1-11ef-96a4-670e87cb73da",
                "list": [],
                "notFound": []
            },
            "c2"
        ]
    ]
}

Expected behaviour

Skip the resync as WE generated the corresponding state...

@chibenwa chibenwa added the bug Something isn't working label Jan 4, 2025
@hoangdat
Copy link
Member

hoangdat commented Jan 6, 2025

From my point of view still have some concerned:

  • can have any case Email/set response the new state but not include all the changes? we worry much about the case of changing from multiple clients at the same time?
  • it still safer for us to have the detail in Email/get, so it maybe only save us one Email/changes method.
  • we also queue and debouncing for websocket message coming, your optimization only work for a single email operation

@chibenwa
Copy link
Member Author

chibenwa commented Jan 6, 2025

can have any case Email/set response the new state but not include all the changes?

Not an issue

If change B happens during change A performed by the client then 2 websocket notifs will be received, A and B

Client will discard A but resync B.

your optimization only work for a single email operation

I am tired to write again and again and again and again and again and again and again and again and again and again and again and again and again and again and again and over again the same thing.

Use a collection of state changes generated by the client ie the last 64.

I already wrote this to Dat VU in another PR.

@hoangdat
Copy link
Member

hoangdat commented Jan 6, 2025

I already wrote this to Dat VU in another PR.

Yes, we implemented it: queue and remove outdated states. So that I don't understand this request.
Please check the test case: https://github.com/linagora/tmail-flutter/blob/671687a823b263a01446f07e942880dcd23e16ee/test/features/push_notification/presentation/websocket/web_socket_queue_handler_test.dart#L332C1-L333C1

@chibenwa
Copy link
Member Author

chibenwa commented Jan 6, 2025

Then why isn;t it working?

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

No branches or pull requests

2 participants