GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Firefox for Android support · Issue #3173 · greasemonkey/greasemonkey

Firefox for Android support #3173

New issue
Copy link
New issue
Copy link
Closed
Closed
Firefox for Android support#3173
Copy link
Milestone
4.12

Description

@arantius
arantius
opened on Nov 5, 2023
Issue body actions

https://blog.mozilla.org/addons/2023/08/10/prepare-your-firefox-desktop-extension-for-the-upcoming-android-release/

It was recently announced that extensions are (finally) coming back to Firefox for Android. An email addressed to me said "Again, we’d love to have your extension be part of the general availability release when it debuts later this year."

Research feasibility and/or implement Firefox for Android support. I don't know when "later this year" is, exactly.

Reacted by Cerberus-tm and Wojtaz0w
Reacted by bunglegrind

Activity

  1. arantius
    added 2 commits that reference this issue on Nov 5, 2023

    Basic Firefox-for-Android support.

    69de938

    Cancel navigation to a `.user.js`.

    6c6cb38
  2. arantius commented on Nov 6, 2023

    @arantius
    arantius
    on Nov 6, 2023
    CollaboratorAuthor
    More actions

    After the above changes, I've: Installed a script, seen it run, opened the editor, changed a script, used a registered menu command. Everything seems to work so far.

    Reacted by Cerberus-tm
  3. arantius
    added this to the 4.12 milestone on Nov 8, 2023
  4. arantius
    added 2 commits that reference this issue on Nov 9, 2023

    Prevent horizontal scroll of monkey menu (on Android).

    f5170dc

    Mobile: Larger (initial?) zoom.

    5c368bc
  5. arantius commented on Nov 11, 2023

    @arantius
    arantius
    on Nov 11, 2023
    CollaboratorAuthor
    More actions

    While working on this I had noticed some occasional unreliability. But of course, I was working on it at the time and it was intermittent. I had planned/hoped to really look into things. But I probably figured it out just by sleeping on it.

    We've probably always had a race condition. When the background script starts ( https://github.com/greasemonkey/greasemonkey/blob/master/src/bg/user-script-registry.run.js#L2 ) we load the user scripts. Separately (i.e. when a page loads) we might want to know which scripts are installed, to choose which to run. If the latter happens too soon, the former will not have (it's async after all) necessarily completed.

    The key here is that ( https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Background_scripts#convert_to_non-persistent ) you have to "convert to non-persistent" background scripts, to run on Android now. I've noticed a warning logged, while developing, that because the dev tools are open, it's not unloading the background page. Makes sense, but also masks this issue while developing!

    So I think we need to make sure that we block on completion of _loadUserScripts() before we service requests.

    Reacted by bunglegrind and Cerberus-tm
  6. Cerberus-tm commented on Nov 11, 2023

    @Cerberus-tm
    Cerberus-tm
    on Nov 11, 2023
    Contributor
    More actions

    Interesting. Block requestions before completion: does that mean the Javascript on the (unedited) page should be unable to make any requests to the Internet until all userscripts are loaded? Or is it only about requests from userscripts?

  7. arantius commented on Nov 11, 2023

    @arantius
    arantius
    on Nov 11, 2023
    CollaboratorAuthor
    More actions

    Sorry by "requests" I was referring to messages sent between content and background. I.e. https://github.com/greasemonkey/greasemonkey/blob/master/doc/Messages.md

  8. Cerberus-tm commented on Nov 11, 2023

    @Cerberus-tm
    Cerberus-tm
    on Nov 11, 2023
    Contributor
    More actions

    Sorry by "requests" I was referring to messages sent between content and background. I.e. https://github.com/greasemonkey/greasemonkey/blob/master/doc/Messages.md

    Ahh that makes sense.

  9. arantius
    added a commit that references this issue on Nov 12, 2023

    Do not process messages before scripts are loaded.

    ae3db6a
  10. arantius commented on Nov 12, 2023

    @arantius
    arantius
    on Nov 12, 2023
    CollaboratorAuthor
    More actions

    When GM.openInTab() is called:

    Error: Type error for parameter createProperties (Property "openerTabId" is unsupported by Firefox) for tabs.create.
    

    on Android. On desktop, it works.

  11. arantius
    added a commit that references this issue on Nov 12, 2023

    Zoom install dialog on mobile.

    e43bf10
  12. arantius commented on Nov 14, 2023

    @arantius
    arantius
    on Nov 14, 2023
    CollaboratorAuthor
    More actions

    Warnings from AMO:

    • browserAction.setIcon is not supported in Firefox for Android version 57.0
      Warning: This API is not implemented by the given minimum Firefox for Android version
      src/bg/options.js line 68 column 8

    • extension.getURL is deprecated
      Warning: This API has been deprecated by Firefox.
      src/bg/options.js line 71 column 18

      And a whole bunch from HTML files inside codemirror; files we should probably remove.

  13. arantius commented on Nov 14, 2023

    @arantius
    arantius
    on Nov 14, 2023
    CollaboratorAuthor
    More actions

    Need to confirm but I'm pretty sure this breaks GM.registerMenuCommand(). RMC works by opening a port (chrome.runtime.connect) between content and background.

    If I add console.log('registered menu commands at', new Date()); to the script registering the command and

    port.onDisconnect.addListener(port => {
      console.warn('port closed!');
    });
    

    To function GM_registerMenuCommand(), then load a page (and otherwise do nothing with that browser) I see:

    registered menu commands at Date Tue Nov 14 2023 11:15:29 GMT-0500 (Eastern Standard Time)
    port closed at Date Tue Nov 14 2023 11:15:59 GMT-0500 (Eastern Standard Time)
    

    In the tab's console. After ~exactly 30 seconds, the port is closed (because the background page suspended?) and the command gets broken. If I keep opening the menu to check, more often than every 30 seconds, causing a message (many messages) to be sent to the background script, I can keep the port alive for at least several minutes.

    (I'm scared that there are several other such subtle bugs hiding from this "simple" change to a non-persistent background script.)

  14. arantius commented on Nov 14, 2023

    @arantius
    arantius
    on Nov 14, 2023
    CollaboratorAuthor
    More actions

    Apparently I was confused; the first link in an email from Mozilla about Android support was "How to convert your extension to non-persistent background scripts". But the support forum says this is not required! (Just, on Android you're more likely to have the process, and the background page with it, evicted. I suspect the page would be restored from cache such that the user scripts would not run, breaking menu commands at that point.)

  15. arantius commented on Nov 14, 2023

    @arantius
    arantius
    on Nov 14, 2023
    CollaboratorAuthor
    More actions

    https://discourse.mozilla.org/t/will-a-runtime-connect-port-keep-a-non-persistent-background-script-alive/124263

  16. arantius
    added a commit that references this issue on Nov 19, 2023

    Disable non-persistent background script.

    66267a1
  17. arantius commented on Nov 29, 2023

    @arantius
    arantius
    on Nov 29, 2023
    CollaboratorAuthor
    More actions

    This should be done. I could use your help testing this! Checkout or download Greasemonkey's source code, then follow the documentation for installing an extension during development.

    Any testing results, positive or negative, would be great.

  18. arantius
    closed this as completedon Dec 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      • 4.12

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.