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

[HOLD for payment 2025-01-22] [$250] Update react-native-qrcode-svg to not use text-decoding #54096

Closed
gedu opened this issue Dec 13, 2024 · 45 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production External Added to denote the issue can be worked on by a contributor NewFeature Something to build that is a new item. Weekly KSv2

Comments

@gedu
Copy link
Contributor

gedu commented Dec 13, 2024

Background

react-native-qrcode-svg relies on the text-encoding library to provide TextDecoder and TextEncoder functionality, which is essential for encoding and decoding text data. However, starting with React Native 0.75, these functionalities are natively supported, making the inclusion of text-encoding redundant for modern environments.
Despite this, the library currently includes text-encoding in all builds, regardless of the React Native version. This results in an unnecessary increase in app bundle size, particularly for developers using React Native 0.75 or higher, where native support for TextDecoder and TextEncoder is already available. This behavior impacts performance and resource usage, especially for applications targeting modern devices.
Reference the relevant issue and commit:
• Issue: Expensify/react-native-qrcode-svg#199
• Commit: 53f1c5f

Problem

The react-native-qrcode-svg library always includes the text-encoding library, adding approximately 600KB to the app bundle size. This is unnecessary for React Native 0.75+ environments, where TextDecoder and TextEncoder are natively supported, leading to inefficiencies in modern applications.

Solution

Update react-native-qrcode-svg to conditionally include the text-encoding library based on the React Native version or the availability of native TextDecoder and TextEncoder. This can be achieved through the following steps:
Version Check:
○ Add conditional logic to detect if the app is running on React Native 0.75 or higher.
○ Exclude the text-encoding library from the bundle if native support for TextDecoder and TextEncoder is available.
Metro Serializer Optimization:
○ Use tools like Metro Serializer Esbuild to further optimize the bundle and ensure unused dependencies like text-encoding are excluded.

Slack: https://expensify.slack.com/archives/C05LX9D6E07/p1734018386310029

Note: Given that we are on 0.75, we can remove text-encoding lib

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021869155133024534590
  • Upwork Job ID: 1869155133024534590
  • Last Price Increase: 2024-12-17
Issue OwnerCurrent Issue Owner: @isabelastisser
@melvin-bot melvin-bot bot added the Monthly KSv2 label Dec 16, 2024
@gedu
Copy link
Contributor Author

gedu commented Dec 17, 2024

Hey @mountiny, Edu from Callstack, I will be working on this one

@gedu
Copy link
Contributor Author

gedu commented Dec 17, 2024

Tasks

  • Remove text-decoding from react-native-qrcode-svg
  • Update Exfy app to use the new react-native-qrcode-svg version

@mountiny mountiny added Weekly KSv2 Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor and removed Monthly KSv2 labels Dec 17, 2024
Copy link

melvin-bot bot commented Dec 17, 2024

Triggered auto assignment to @isabelastisser (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

@melvin-bot melvin-bot bot added the Daily KSv2 label Dec 17, 2024
@melvin-bot melvin-bot bot changed the title Update react-native-qrcode-svg to not use text-decoding [$250] Update react-native-qrcode-svg to not use text-decoding Dec 17, 2024
Copy link

melvin-bot bot commented Dec 17, 2024

Job added to Upwork: https://www.upwork.com/jobs/~021869155133024534590

@melvin-bot melvin-bot bot added Help Wanted Apply this label when an issue is open to proposals by contributors and removed Weekly KSv2 labels Dec 17, 2024
Copy link

melvin-bot bot commented Dec 17, 2024

Triggered auto assignment to Contributor-plus team member for initial proposal review - @thesahindia (External)

@mountiny mountiny removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Dec 17, 2024
@gedu
Copy link
Contributor Author

gedu commented Dec 18, 2024

I confirmed that removing the line:

global.TextEncoder = require("text-encoding").TextEncoder;

our app will tree shake that lib and won't be on the final bundle. Now I'm looking into a way to adding that line for old RN versions

@AbdulrhmnGhanem
Copy link

Hi @gedu, I see you are working on the issue already, I saw it yesterday and wanted to experiment with it before commenting. Feel free to continue on with my PR!

Copy link

melvin-bot bot commented Dec 18, 2024

📣 @AbdulrhmnGhanem! 📣
Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:

  1. Make sure you've read and understood the contributing guidelines.
  2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
    Screen Shot 2022-11-16 at 4 42 54 PM
    Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

@gedu
Copy link
Contributor Author

gedu commented Dec 19, 2024

@AbdulrhmnGhanem Hey, thanks for your PR. The main idea of the issue is to remove the text-encoder to reduce the bundle size, your approach always keeps the lib into the bundle. So it won't work.

@AbdulrhmnGhanem
Copy link

AbdulrhmnGhanem commented Dec 19, 2024 via email

@gedu
Copy link
Contributor Author

gedu commented Dec 20, 2024

@mountiny I created a PR using the metro solution, on Exfy app the only thing we have to do is increase the version and that's all.

@isabelastisser
Copy link
Contributor

FYI, I will be OOO from Dec 23 to Jan 6, so please reassign the issue to another team member for urgency, IF needed.

@mountiny
Copy link
Contributor

@gedu can you link the pr here please?

@gedu
Copy link
Contributor Author

gedu commented Jan 8, 2025

I'm looking into a possible Example App issue, and will continue updating the version @mountiny I still see that the last version is 6.3.12, shouldn't it be 6.3.13?

@melvin-bot melvin-bot bot removed the Overdue label Jan 8, 2025
@mountiny
Copy link
Contributor

mountiny commented Jan 8, 2025

Fixing the publishing flow that seems broken

Copy link

melvin-bot bot commented Jan 10, 2025

@gedu @parasharrajat @isabelastisser @mountiny this issue is now 4 weeks old, please consider:

  • Finding a contributor to fix the bug
  • Closing the issue if BZ has been unable to add the issue to a VIP or Wave project
  • If you have any questions, don't hesitate to start a discussion in #expensify-open-source

Thanks!

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Jan 10, 2025
@gedu
Copy link
Contributor Author

gedu commented Jan 10, 2025

PR created: #55080

@mountiny
Copy link
Contributor

@gedu anything else left to do here?

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Jan 15, 2025
@melvin-bot melvin-bot bot changed the title [$250] Update react-native-qrcode-svg to not use text-decoding [HOLD for payment 2025-01-22] [$250] Update react-native-qrcode-svg to not use text-decoding Jan 15, 2025
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jan 15, 2025
Copy link

melvin-bot bot commented Jan 15, 2025

Reviewing label has been removed, please complete the "BugZero Checklist".

Copy link

melvin-bot bot commented Jan 15, 2025

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.85-4 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2025-01-22. 🎊

For reference, here are some details about the assignees on this issue:

  • @gedu does not require payment (Contractor)
  • @parasharrajat requires payment through NewDot Manual Requests

Copy link

melvin-bot bot commented Jan 15, 2025

@parasharrajat @isabelastisser @parasharrajat The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

@gedu
Copy link
Contributor Author

gedu commented Jan 15, 2025

All good here

@mountiny
Copy link
Contributor

So only payments to @parasharrajat

@parasharrajat
Copy link
Member

This is a new feature not bug. Let's fix the labels.

@parasharrajat
Copy link
Member

Regression Test Steps

  1. Open a Workspace
  2. Click the top bar to get into the Workspace's Profile
  3. Click on Share button
  4. The QRcode should show up

Do you agree 👍 or 👎 ?

@mountiny
Copy link
Contributor

I think we should already have tests like this

@mountiny mountiny added NewFeature Something to build that is a new item. and removed Bug Something is broken. Auto assigns a BugZero manager. labels Jan 15, 2025
Copy link

melvin-bot bot commented Jan 15, 2025

Current assignee @isabelastisser is eligible for the NewFeature assigner, not assigning anyone new.

@isabelastisser
Copy link
Contributor

Payment summary:

@parasharrajat requires payment through NewDot Manual Requests $250 for C+ review

@parasharrajat
Copy link
Member

Payment requested as per #54096 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production External Added to denote the issue can be worked on by a contributor NewFeature Something to build that is a new item. Weekly KSv2
Projects
Development

No branches or pull requests

6 participants