sample-extensions icon indicating copy to clipboard operation
sample-extensions copied to clipboard

messageDiplay example do not work on MacOS version

Open jarimustonen opened this issue 3 years ago • 34 comments

Thunderbird version: 102.2.2 (64-bit), language: FI Plugin: [email protected]

The plugin was loaded using the Load temporary plug-in functionality.

The button becomes visible, but when pressed, the popup window has no content.

Näyttökuva 2022-9-10 kello 15 20 06

I modified plugin.js a bit to get some debug information:

browser.tabs.query({
  active: true,
  currentWindow: true,
}).then(tabs => {
  let tabId = tabs[0].id;
  browser.messageDisplay.getDisplayedMessage(tabId).then((message) => {
    document.body.textContent = message.subject;
    console.log(document.body)
  });
});

Here's what I can see on console:

Näyttökuva 2022-9-10 kello 15 18 54

jarimustonen avatar Sep 10 '22 12:09 jarimustonen

I took the screenshot as I thought the labels containing the text "Invalid object" would be important.

jarimustonen avatar Sep 10 '22 12:09 jarimustonen

Thunderbird version: 102.3 (64-bit) Macos 10.15

I also encountered the same problem. Were you able to find a solution to this issue?

jporminal avatar Sep 26 '22 09:09 jporminal

Seems to be related to https://bugzilla.mozilla.org/show_bug.cgi?id=1725630

I have not yet been able to reproduce this myself, which makes it hard to fix.

jobisoft avatar Sep 26 '22 10:09 jobisoft

I am on macOS Monterey 12.4 where I cannot reproduce this.

@arndissler @jporminal @jarimustonen Is this issue limited to macOS 10.* and macOS 11.* ?

Do we have evidence it happens on recent macOS 12.* ?

jobisoft avatar Sep 26 '22 10:09 jobisoft

I do get the invalid object in the log, but that seems not to be related to the issue, as I see the content of the popup.

jobisoft avatar Sep 26 '22 10:09 jobisoft

I found a workaround. Setting browser.tabs.remote.autostart to false fixed the issue for me.

This was mentioned on the comments in the link you provided https://bugzilla.mozilla.org/show_bug.cgi?id=1725630

jporminal avatar Sep 26 '22 10:09 jporminal

I am on macOS Monterey 12.4 where I cannot reproduce this.

@arndissler @jporminal @jarimustonen Is this issue limited to macOS 10.* and macOS 11.* ?

Do we have evidence it happens on recent macOS 12.* ?

I'm using Mac OS 12.5.1. We are also seeing this on a standard out-of-the-box Ubuntu.

jarimustonen avatar Sep 26 '22 10:09 jarimustonen

I found a workaround. Setting browser.tabs.remote.autostart to false fixed the issue for me.

This is not a real fix, as it disables fission and removes the extra security layer between tabs. It is related to that change, yes, but I hoped it was only affecting older macOS.

Edit: So even if it fixes it for you, I wanted to make you aware of the implications.

jobisoft avatar Sep 26 '22 11:09 jobisoft

We are also seeing this on a standard out-of-the-box Ubuntu.

That is totally unexpected and first time I ever hear that. Since it affects two of your systems, is there a common configuration which is applied to both of them? Any security suits installed?

Into the blue: What happens if you disconnect them from any network?

jobisoft avatar Sep 26 '22 11:09 jobisoft

I don't think there are any commonalities in our system. I just asked my son to run the code in his Linux box. He installed Thunderbird for that purpose. We'll try this again as the initial test was with a bit different extension. (We tested a "hello world" extension that we copied from this extension.)

I tested this with a disconnected network and the behavior is the same.

jarimustonen avatar Sep 26 '22 11:09 jarimustonen

https://bugzilla.mozilla.org/show_bug.cgi?id=1725630#c21

Here you mention that printing this.extension.browsingContextGroupId. At which point this is available. I'm trying to ask what this refers to.

Are there other options to have some debugging run? I can provide it if instructions are presented.

On a related note, I did add a lot of console logging, and the plugin code gets executed. Also, the document DOM-tree gets updated. It just does not become visible to UI.

jarimustonen avatar Sep 26 '22 11:09 jarimustonen

We are also seeing this on a standard out-of-the-box Ubuntu.

That is totally unexpected and first time I ever hear that. Since it affects two of your systems, is there a common configuration which is applied to both of them? Any security suits installed?

Ok. We tested this again and the popup remains empty. Also, the popup does not have content even in the first run. So it stays empty always. Thunderbird version is 102.3.0.

jarimustonen avatar Sep 26 '22 11:09 jarimustonen

https://bugzilla.mozilla.org/show_bug.cgi?id=1725630#c21

Here you mention that printing this.extension.browsingContextGroupId. At which point this is available. I'm trying to ask what this refers to.

Are there other options to have some debugging run? I can provide it if instructions are presented.

On a related note, I did add a lot of console logging, and the plugin code gets executed. Also, the document DOM-tree gets updated. It just does not become visible to UI.

  1. Make sure that the example add-on is loaded and that you tried to open the pop-up at least once, so all required code has been loaded.
  2. Open the debugger (app menu -> Tools -> Developer Tools) and switch to its Debugger tab

image

  1. Press CTRL + P and enter ExtensionPopups.jsm into the field and select the file.

  2. Go below the code block mentioned in the bug:

    browser.setAttribute(
      "initialBrowsingContextGroupId",
      this.extension.policy.browsingContextGroupId
    );

For me this is line 277, and set a breakpoint there (click on line number)

  1. Add a expression to the watch list on the right:
  • this.extension.policy.browsingContextGroupId
  • this.extension.browsingContextGroupId
  • this.extension image

Open the pop-up and observe the debugger, which will hold execution at the breakpoint:

image

What do you get?

jobisoft avatar Sep 26 '22 12:09 jobisoft

Another shot into the blue: Select a message without any non ascii-characters in the subject

jobisoft avatar Sep 26 '22 12:09 jobisoft

What is your Thunderbird locale?

jobisoft avatar Sep 26 '22 12:09 jobisoft

For me the bug seems to be independent from locale or macOS version. I've tested it with de_DE and en_US and the bug occurs even on Big Sur.

Can confirm the bug on macOS occurs still in 102.3.0 and 106.0b1, both on Intel (not M1/2 Apple Silicon), macOS v12.5.1 (Monterey).

arndissler avatar Sep 26 '22 22:09 arndissler

There is one more differentiation we have to do: Does the pop-up correctly show the first time after a fresh Thunderbird restart? This is what Bug https://bugzilla.mozilla.org/show_bug.cgi?id=1725630 is about.

@jarimustonen @jporminal Are you seeing it work once or not at all?

jobisoft avatar Sep 27 '22 05:09 jobisoft

For me the bug seems to be independent from locale or macOS version. I've tested it with de_DE and en_US and the bug occurs even on Big Sur.

Can confirm the bug on macOS occurs still in 102.3.0 and 106.0b1, both on Intel (not M1/2 Apple Silicon), macOS v12.5.1 (Monterey).

I am on Apple Silicon, and I am not seeing this, so that is something to look out for.

jobisoft avatar Sep 27 '22 05:09 jobisoft

There is one more differentiation we have to do: Does the pop-up correctly show the first time after a fresh Thunderbird restart? This is what Bug https://bugzilla.mozilla.org/show_bug.cgi?id=1725630 is about.

@jarimustonen @jporminal Are you seeing it work once or not at all?

As I've tested this repeatedly, it's both. Sometimes the content appears on the first try, but most of the time, the content does not even appear the first time.

P.S. I'll respond to you about the other points and debugging information later today.

jarimustonen avatar Sep 27 '22 05:09 jarimustonen

I am on Apple Silicon, and I am not seeing this, so that is something to look out for.

I use an M1 processor so it's not that.

jarimustonen avatar Sep 27 '22 05:09 jarimustonen

What do you get?

Here's the result:

Screenshot of break point
  • this.extension.policy.browsingContextGroupId: 45
  • this.extension.browsingContextGroupId: 45

jarimustonen avatar Sep 27 '22 06:09 jarimustonen

And I assume the values do not change if you click on the button for a second time? We did this on Arnd's system in the add-on developer meeting yesterday and found it to stay the same.

jobisoft avatar Sep 27 '22 06:09 jobisoft

Another shot into the blue: Select a message without any non ascii-characters in the subject

I'm unable to find a such message so it's probably not that.

The behavior stays the same with the following change so it's probably not the content of subject.

Original:

document.body.innerText = message.subject;

New:

document.body.innerText = "Test";

jarimustonen avatar Sep 27 '22 06:09 jarimustonen

What is your Thunderbird locale?

I'm using the standard EN_us version, or so I think. I also suspected this, so I reinstalled Thunderbird with the old locale being FI_fi.

Edit: Here are the settings:

Localization settings

jarimustonen avatar Sep 27 '22 06:09 jarimustonen

And I assume the values do not change if you click on the button for a second time? We did this on Arnd's system in the add-on developer meeting yesterday and found it to stay the same.

Yes. It stays the same. (After restarting Thunderbird the value was 46.)

jarimustonen avatar Sep 27 '22 07:09 jarimustonen

Here's a funny observation. The width of the subject affects the size of the popup box!

I have two examples. Here's the subject is Digitaidot kunnolla vauhtiin:

Short subject

Here the subject is VS: Muista aloittaa Digitaidot kunnolla vauhtiin -koulutus:

Long subject

Could it be that we have white on white text? But why the difference with the first run? Is there a way to set the color manually?

Edit: I tried to modify text color with the following but this didn't seem to work:

document.body.innerHTML = '<span style="color: black">' + message.subject + '</span>';

jarimustonen avatar Sep 27 '22 07:09 jarimustonen

By the way, maybe it's due to the debugging breakpoints and watched variables or what not but the following do not work anymore:

browser.tabs.query({
  active: true,
  currentWindow: true,
}).then(tabs => {
  let tabId = tabs[0].id;
  browser.messageDisplay.getDisplayedMessage(tabId).then((message) => {
    document.body.textContent = message.subject;
    console.log('body', document.body);
  });
});

It just prints:

 body <unavailable>

Maybe it's related, maybe it's not.

jarimustonen avatar Sep 27 '22 07:09 jarimustonen

We've made the experience that there are some restrictions to what WE can print using console.log. Try a local copy: let b = document.body; console.log(b);

Betterbird avatar Dec 01 '22 11:12 Betterbird

We've made the experience that there are some restrictions to what WE can print using console.log. Try a local copy: let b = document.body; console.log(b);

Hi

Thank you for the message, and sorry for the delayed response. Here's the popup.js that I'm now using:

browser.tabs.query({
  active: true,
  currentWindow: true,
}).then(tabs => {
  let tabId = tabs[0].id;
  browser.messageDisplay.getDisplayedMessage(tabId).then((message) => {
    let b = document.body; console.log(b);
    document.body.textContent = message.subject;
  });
});

The new addition is at line 7.

Here's the console log with Betterbird:

Screenshot 2022-12-30 at 10 33 03

The log is identical also with Thunderbird.

Important observations:

  1. When the plugin is loaded for the first time and the button is pressed for the first time, the text becomes visible. (So the button works.) Only on consecutive button pushes is the text hidden.
  2. The console log is identical in both cases.
  3. The text printed is the message subject. Even in the case that the text does not show, the subject length affects the box size as if the text color changes to while on white.

jarimustonen avatar Dec 30 '22 08:12 jarimustonen

This looks like a bug deep down in the Mozilla platform code where the text is rendered into the UI. Sadly the issue is hard to reproduce, and the Mozilla/Firefox developers (understandably) don't want to investigate issues which are only demonstrable in Thunderbird (if at all). Most of the TB developers are not familiar with Mozilla platform code. This split in responsibilities has been a problem for decades with many bugs being left unsolved.

Betterbird avatar Dec 30 '22 10:12 Betterbird