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

Fix FCM rxjs Incompatibility #3221

Merged
merged 44 commits into from
Jul 6, 2020
Merged

Fix FCM rxjs Incompatibility #3221

merged 44 commits into from
Jul 6, 2020

Conversation

zwu52
Copy link
Member

@zwu52 zwu52 commented Jun 16, 2020

Fixes #3142

Adding a field variable to hold rxjs observer or subscriber. It enables onMessage(nextFn) and onMessage(observer) to both execute if both are set.

Kai Wu and others added 30 commits April 14, 2020 11:00
Context: the tests were switched off a couple of years ago due to flakiness. It has not been maintained since then. During the time, Some Selenium API methods used were deprecated and removed; the Firebase projects used are no longer managed or owned by the FCM team. Consequently, the test became unfunctional. In the effort of providing safety for the upcoming FCM releases, this PR is created to fix, deflake, refactor and improve the old tests.

This PR did the following:
- Enabled comprehensive IT for chrome (ver.80). Now we are covering send&foreground recevie for FCM messages (messages with {notification} payload, {data} payload and {notification, data} payload), delete/update token, use default/customized ServiceWorker.

- Defalaked test. The IT is now reasonably stable without retry. Previously we are retrying 1 or 3 times.

- Optimized test. Previously we create a webDriver for each test, which is slow and annoying. Because a window is created and brought to focus and killed frequently, it makes working on other tasks and testing nearly impossible (Probably using a headless browser would work but I haven't found a satisfying solution to have the app in the state of foreground and background which is a requirement for FCM functions). With the way the tests are organized, the IT only spin up a new web driver when necessary. Some data on performance: (old) 'test-send' take 74 seconds (only measured 'test-send' because the other test suites were not functional at the time); (now) 'test-send', 'test-deleteToken', 'test-updateToken', 'test-useDefaultServiceWorker', 'test-useValidManifest' takes in total 33s (10 run average).

- General refactoring. Including refactors on expect blocks, createWebDriver, use const for constants usage, etc. The code should be much easier to understand and maintain.

Future work:
- Enable test on firefox once I get the notification permission working.
- Run the IC against some milestone chrome/firefox version (if it makes sense) to ensure backward compatibility. We should try to avoid #2712 . :)
Context: FCM IT were turned off a couple years ago due to flakiness. It became mostly unfunctional as repo structure change overtime. The goal is to fix and enable IT for more confident developement flow and safer releases.

This CL does the following:
- Fix the IT to be functional again. The IT is derteminated from my experiements (no longer flaky). Therefore, The CL removed the retry mechasim (previously retry 3 times) which makes running IT cheaper and more enjoyable.

- Include IT for test:change for FCM package: the entire IT test suites is resoanblly fast (from my exeperience 1-3 miutes to complete. As it grows larger, maybe it makes run tests in parallel in Saucelab)

Futhure work:
- Enable testing for firefox
js doesn't allow underscore for int
why dot.env(FCM_SECRETS) are not included in env?
Because headless chrome doesn't have the concept of foreground and background
@google-oss-bot
Copy link
Contributor

google-oss-bot commented Jun 16, 2020

Binary Size Report

Affected SDKs

  • @firebase/firestore

    Type Base (ddbe218) Head (4d040f3) Diff
    browser 248 kB 248 kB -603 B (-0.2%)
    esm2017 194 kB 193 kB -527 B (-0.3%)
    main 494 kB 492 kB -1.34 kB (-0.3%)
    module 246 kB 245 kB -593 B (-0.2%)
  • @firebase/firestore/exp

    Type Base (ddbe218) Head (4d040f3) Diff
    main 37.5 kB 272 kB +234 kB (+625.1%)
  • @firebase/firestore/lite

    Type Base (ddbe218) Head (4d040f3) Diff
    main 140 kB 140 kB -8 B (-0.0%)
  • @firebase/firestore/memory

    Type Base (ddbe218) Head (4d040f3) Diff
    browser 186 kB 186 kB -603 B (-0.3%)
    esm2017 145 kB 145 kB -527 B (-0.4%)
    main 363 kB 362 kB -1.34 kB (-0.4%)
    module 184 kB 184 kB -593 B (-0.3%)
  • @firebase/messaging

    Type Base (ddbe218) Head (4d040f3) Diff
    esm2017 23.2 kB 23.2 kB +35 B (+0.2%)
    main 31.3 kB 31.4 kB +35 B (+0.1%)
    module 30.9 kB 30.9 kB +35 B (+0.1%)
  • firebase

    Type Base (ddbe218) Head (4d040f3) Diff
    firebase-firestore.js 287 kB 286 kB -593 B (-0.2%)
    firebase-firestore.memory.js 226 kB 225 kB -593 B (-0.3%)
    firebase-messaging.js 39.1 kB 39.2 kB +43 B (+0.1%)
    firebase.js 820 kB 819 kB -551 B (-0.1%)

Test Logs

packages/messaging/src/controllers/window-controller.ts Outdated Show resolved Hide resolved
@zwu52 zwu52 requested a review from Feiyang1 June 24, 2020 23:14
…into fix-fcm-observer

Sync to head to pick up changeset related chnages
@zwu52 zwu52 requested a review from hiranya911 as a code owner June 26, 2020 21:21
@changeset-bot
Copy link

changeset-bot bot commented Jun 26, 2020

🦋 Changeset is good to go

Latest commit: 4aca0f2

We got this.

This PR includes changesets to release 10 packages
Name Type
firebase Patch
@firebase/messaging Patch
@firebase/testing Patch
firebase-browserify-test Patch
firebase-package-typings-test Patch
firebase-messaging-selenium-test Patch
firebase-typescript-test Patch
firebase-webpack-test Patch
@firebase/functions Patch
@firebase/functions-exp Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@zwu52 zwu52 merged commit 469c8bd into master Jul 6, 2020
@github-actions github-actions bot mentioned this pull request Jul 7, 2020
@firebase firebase locked and limited conversation to collaborators Aug 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FCM rxjs compatibility broken?
3 participants