online icon indicating copy to clipboard operation
online copied to clipboard

Hyperlink preview glitch

Open pedropintosilva opened this issue 1 year ago • 2 comments

Describe the Bug

Hyperlink preview glitch (keeps flickering). We keep receiving the same postmessage over and over.

Steps to Reproduce

  1. Multiple users: Open a text office file with hyperlinks using Nextcloud
  2. One user moves the text cursor above one of the hyperlinks
  3. Preview appears but keeps flashing
  4. See the errors in the web console log

Logs

May 09 2024

I was able to reproduce this again, I think:

https://github.com/CollaboraOnline/online/assets/65948705/7b9850a3-8dae-447d-a2a5-e7290870172c

One user is sitting - without moving the text cursor - on a hyperlink while the other user edits text. In this test both used FF. But I think @mmeeks tried the same test and we couldn't reproduce it so maybe there is one more step I'm missing here.

console-export-2024-5-9_16-3-45.txt

Oct 2023

For example multiple previews coming from the same exact url https://github.com/CollaboraOnline/online/issues/7256:

See the logs from Oct 2023: console-export-2023-10-12_12-6-46.txt

Expected Behavior

We probably shouldn't be fetching the same preview multiple times

Actual Behavior

It seems we are fetching the preview multiple times

Screenshots

If applicable, add screenshots to help explain your problem.

Desktop

Firstly reported on Oct 12 2023 https://forum.collaboraonline.com/t/community-weekly-meeting-140/2129#online-activity-4

COOLWSD version: 23.05.5.1 (git hash: dffef0e9 (E)) LOKit version: Collabora Office 23.05.5.1 (git hash: 9f03693) Served by: openSUSE Leap 15.5 Server ID: 3a813eff

Latest observed on May 09 2024

Today in the Community Meeting the hash was on https://github.com/CollaboraOnline/online/commits/f4265ce8

pedropintosilva avatar May 09 '24 14:05 pedropintosilva

Past of my analysis:

  • Stack trace:

    TLDR; cause is getting "invalidatecursor:" messages left & right + these can be caused by other user's actions moving the view.

    • weirdly we are getting 'invalidatecursor' for different view-ids.

    • also duplicate 'editor: ' messages back to back (!?)

PostMessageService.sendPostMessage (postMessage.tsx:52)

(anonymous) (document.js:404)

      // Pass all messages to viewer if not direct editing or
      if (!isDirectEditing() && ViewerToLool.indexOf(msgId) === -1) {
        PostMessages.sendPostMessage('parent', data);
      }

(anonymous) (postMessage.tsx:107)

  try {
    fn({
      data: data,
      parsed: parsed
    });
  } catch (e) {
    console.error('Error during post message handler', parsed, e);
  }

PostMessageService.handlePostMessage (postMessage.tsx:101)

this.postMessageHandlers.forEach(function (fn) {

-> only one postMessageHandler

(anonymous) (postMessage.tsx:38)

window.addEventListener('message', function (event) {
  _this.handlePostMessage(event.data);
}, false);

postMessage (async)

            var msg = {
                MessageId: msgId,
                SendTime: Date.now(),
                Values: values
            };
            window.parent.postMessage(JSON.stringify(msg), this.PostMessageOrigin)

_postMessage (bundle.js:21766)

            for (id in typeIndex) {
                typeIndex[id].fn.call(typeIndex[id].ctx, event)
            }

fire (bundle.js:9863)

_showURLPopUp (bundle.js:16303)

        if (this._map["wopi"].EnableRemoteLinkPicker)
            this._map.fire("postMessage", {
                msgId: "Action_GetLinkPreview",
                args: {
                    url: url
                }
            })

_onInvalidateCursorMsg (bundle.js:16324)

        this._map.lastActionByUser = false;
        this._map.hyperlinkUnderCursor = obj.hyperlink;
        this._closeURLPopUp();
        if (obj.hyperlink && obj.hyperlink.link) {
            this._showURLPopUp(this._map._docLayer._twipsToLatLng({
                x: app.file.textCursor.rectangle.x1,
                y: app.file.textCursor.rectangle.y1
            }), obj.hyperlink.link)
        }

_onMessage (bundle.js:15961)

        } else if (textMsg.startsWith("invalidatecursor:")) {
            this._onInvalidateCursorMsg(textMsg)

_onMessage (bundle.js:10216)

        if (!this._map._docLayer || this._handlingDelayedMessages) {
            this._delayMessage(textMsg)
        } else {
            this._map._docLayer._onMessage(textMsg, e.image)
        }

_emitSlurpedEvents (bundle.js:9970) (anonymous) (bundle.js:9957) setTimeout (async) _queueSlurpEventEmission (bundle.js:9957) _slurpMessage (bundle.js:9977)

Log is online-url-popup.log

mmeeks avatar May 09 '24 14:05 mmeeks

When checking this with Pedro in our call it seems that every keystroke of other people is triggering Action_GetLinkPreview post messages to Nextcloud to get the metadata.

In addition there seem to be multiple post messages sent on own cursor move to Nextcloud, not sure if that is inteded or related:

Screenshot 2024-08-27 at 13 55 02

juliusknorr avatar Aug 27 '24 11:08 juliusknorr

Seems rather important to fix =) thanks Julius.

mmeeks avatar Sep 06 '24 13:09 mmeeks

Patch to review: https://gerrit.libreoffice.org/c/core/+/173726

GulsahKose avatar Sep 25 '24 10:09 GulsahKose

@eszkadev I've updated the patch. Here is the screen record. Everything seem ok. Screencast from 2024-09-26 14-44-17.webm

GulsahKose avatar Sep 26 '24 11:09 GulsahKose

merged, @Ezinnem @jazevedo-coll could you test at some point?

eszkadev avatar Oct 01 '24 08:10 eszkadev

it was reverted due to cypress fails: https://gerrit.libreoffice.org/c/core/+/174323

eszkadev avatar Oct 01 '24 13:10 eszkadev

could you test at some point?

Yes, when there is a new patch.

jazevedo-coll avatar Oct 02 '24 18:10 jazevedo-coll

I've send new patch https://gerrit.libreoffice.org/c/core/+/174813

GulsahKose avatar Oct 11 '24 13:10 GulsahKose