[Bug] Read button doesn't appear if an article is opened in the main app from a custom tab
Steps to reproduce
- Open article in a custom tab
- Use three dot menu to open in Firefox Preview
Expected behavior
Read button appears alongside share sand bookmark buttons
Actual behavior
Only share and bookmark buttons appear. Refreshing the page will cause the read button to now appear as expected.
Device information
- Android device: Pixel 3 - Android 10 (Sept Patch)
- Fenix version: Nightly 190919 18:00 (Build #12621820) 📦: 14.0.0, 0681a1e65 🦎: 71.0a1-20190916093313
┆Issue is synchronized with this Jira Task
I investigated this bug and the problem is that when you open a custom tab in Firefox Preview, the onPortMessage callback from ReaderViewContentMessageHandler is not triggered and therefore the ReaderActiveStateChange is not changing in initializeUI, so the Read button remains hidden.
I tried to manually call checkReaderable but seems like the port is not connected for the active session thus extensionController.portConnected(engineSession) returning false, so I'm currently stuck going forward with this proposed solution.
Does anybody has any idea on how to proceed with the above scenario or has any other solution?
@ValentinTimisica Yes, the reason for this is that the content script (readerview.js) injected by the ReaderViewFeature web extension runs when the page is loaded. If the page is loaded in a CustomTab, it won't run at all, because we don't start this feature for custom tabs. When the tab is then opened in / migrated to the main app it is too late. The page has already loaded. If you reload, you will see it working.
Since we don't want to reload in this case, we would have to start the ReaderViewFeature for custom tabs as well. This would require the following changes:
- In Fenix: Start the
ReaderViewFeaturein theBaseBrowserFragmentinstead of theBrowserFragment - In A-C: Allow the
ReaderViewFeatureto operate on a specific (provided) session, not just the selected session
So, it's not a straight forward fix, unfortunately.
See: https://github.com/mozilla-mobile/fenix/issues/17373 This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.