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: Find solution to low resolution large images on Android, and the Canvas crash #20798

Merged
merged 161 commits into from
Aug 7, 2023

Conversation

chrispader
Copy link
Contributor

@chrispader chrispader commented Jun 15, 2023

Details

Fixed Issues

$ #18963
PROPOSAL: GH_LINK_ISSUE(COMMENT)

Tests

On iOS/Android:

  1. Go to a report/chat with a large attachments in it (example image)
  2. Open an attachment image
  3. Make sure the app doesn't crash
  4. Make sure gestures are smooth and easy to use
  5. Make sure low resolution large images are displayed correctly and zooming works.
  6. Make sure other attachment types (PDF, etc.) still work
  • Verify that no errors appear in the JS console

Offline tests

None needed.

QA Steps

Same as in "Tests"

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android / native
    • Android / Chrome
    • iOS / native
    • iOS / Safari
    • MacOS / Chrome / Safari
    • MacOS / Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I verified the translation was requested/reviewed in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR author checklist, including those that don't apply to this PR.

Screenshots/Videos

Web

Screenshot 2023-06-23 at 10 55 03
Screenshot 2023-06-23 at 10 55 08
Screenshot 2023-06-23 at 10 55 11
Screenshot 2023-06-23 at 10 55 13
Screenshot 2023-06-23 at 10 55 16

Mobile Web - Chrome

Screenshot_20230628_120056_Chrome

Screenshot_20230628_120005_Chrome

Screenshot_20230628_115939_Chrome

Mobile Web - Safari

Simulator Screen Shot - iPhone 14 Pro (16 2) - 2023-06-23 at 14 04 26
Simulator Screen Shot - iPhone 14 Pro (16 2) - 2023-06-23 at 14 04 32

Desktop

Screenshot 2023-06-23 at 11 03 11

Screenshot 2023-06-23 at 11 02 50

iOS
Simulator.Screen.Recording.-.14Pro.-.2023-07-19.at.14.05.38.mp4

Simulator Screen Shot - iPhone 14 Pro (16 2) - 2023-06-23 at 11 04 22
Simulator Screen Shot - iPhone 14 Pro (16 2) - 2023-06-19 at 16 38 24
Simulator Screen Shot - iPhone 14 Pro (16 2) - 2023-06-19 at 16 29 52

Android

Uploading Screen_Recording_20230719_132241_Expensify Chat.mov…

Screenshot_20230628_114416_New Expensify

Screenshot_1687511340
Screenshot_1687511324

@chrispader
Copy link
Contributor Author

@Julesssss most of the code is already working, but still WIP, so i'll try to finish everything up tomorrow, once i got some replies on this slack thread :)

@melvin-bot
Copy link

melvin-bot bot commented Aug 7, 2023

@Julesssss looks like this was merged without a test passing. Please add a note explaining why this was done and remove the Emergency label if this is not an emergency.

@OSBotify
Copy link
Contributor

OSBotify commented Aug 7, 2023

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@Julesssss
Copy link
Contributor

@Julesssss looks like this was merged without a test passing. Please add a note explaining why this was done and remove the Emergency label if this is not an emergency.

WRONG

@OSBotify
Copy link
Contributor

OSBotify commented Aug 7, 2023

🚀 Deployed to staging by https://github.com/Julesssss in version: 1.3.51-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@Julesssss
Copy link
Contributor

@chrispader could you please take a look at the above issue to confirm? thanks

@OSBotify
Copy link
Contributor

OSBotify commented Aug 9, 2023

🚀 Deployed to production by https://github.com/Julesssss in version: 1.3.51-2 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

OSBotify commented Aug 9, 2023

🚀 Deployed to staging by https://github.com/Julesssss in version: 1.3.52-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 failure ❌
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

OSBotify commented Aug 9, 2023

🚀 Deployed to staging by https://github.com/Julesssss in version: 1.3.52-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

Comment on lines +47 to +56
const initialPage = _.findIndex(attachments, (a) => a.source === source);
if (initialPage === -1) {
Navigation.dismissModal();
return {
attachments: [],
initialPage: 0,
initialItem: undefined,
initialActiveSource: null,
};
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously, an error was thrown that displayed a message to the user.

Why have we modified this to potentially deny the client's request without any context?

If we're confident that this error is no longer possible, we might not need to handle the -1 case.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we stick with dismissing the modal or go back to throwing an error? To me it also seems more logical to show the user a "Something went wrong" page and log the error... cc @kidroca @fedirjh

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


const {windowWidth, isSmallScreenWidth} = useWindowDimensions();

const {attachments, initialPage, initialActiveSource, initialItem} = useMemo(() => extractAttachmentsFromReport(report, reportActions, source), [report, reportActions, source]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously, when the component was class-based, this operation was executed only once. However, it now appears to be triggered whenever source changes. I understand this can happen when navigating to a different attachment or when new messages are received (i.e., when reportActions change).

Given this, if a report has numerous reportActions, we might be processing and extracting attachments from all actions repeatedly each time we navigate. Is this the intended behavior?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good question to ask! Can you maybe raise that in the expensify open source channel, so we can all discuss it? I am afraid it doesn't have enough visibility here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on this Slack comment i think we can put this aside for now, as this needs a new feature predesign?

Happy to work on this, once we decided on a final approach.

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/puneetlath in version: 1.3.52-5 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

file={item.file}
isAuthTokenRequired={item.isAuthTokenRequired}
isFocused={activeSource === item.source}
onPress={() => canUseTouchScreen && setShouldShowArrows(!shouldShowArrows)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this change introduced regression here #25796

const [containerDimensions, setContainerDimensions] = useState({width: 0, height: 0});
const [page, setPage] = useState(initialPage);
const [activeSource, setActiveSource] = useState(initialActiveSource);
const [isPinchGestureRunning, setIsPinchGestureRunning] = useState(true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,
Because the default value was true, we caused Navigation arrows are not shown on PDF until navigated to an image

More details here #24375 (comment)

Comment on lines +47 to +49
const initialPage = _.findIndex(attachments, (a) => a.source === source);
if (initialPage === -1) {
Navigation.dismissModal();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we upload an attachment offline and open it. Then after coming back online the source will change and the modal will be dismissed. (Coming from #48173)

PS: The bug could only be reproduced after #44889 which enables the attachment preview while offline.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this fixed somewhere else or do we still need to fix this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in #49832

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.