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

Removing last page when it's active causes a crash in iOS on RN 0.64 #465

Closed
duailibe opened this issue Oct 21, 2021 · 5 comments · Fixed by #466 or #467
Closed

Removing last page when it's active causes a crash in iOS on RN 0.64 #465

duailibe opened this issue Oct 21, 2021 · 5 comments · Fixed by #466 or #467

Comments

@duailibe
Copy link
Contributor

duailibe commented Oct 21, 2021

Environment

  • react-native: 0.63.4
  • react-native-pager-view: 5.4.7

Description

If we remove the last child of the PagerView, when it's active, iOS crashes with:

Exception thrown while executing UI block: *** -[__NSArrayM objectAtIndexedSubscript:]: index 4 beyond bounds [0 .. 3]

__44-[RCTUIManager flushUIBlocksWithCompletion:]_block_invoke
    RCTUIManager.m:1199
__44-[RCTUIManager flushUIBlocksWithCompletion:]_block_invoke.496
__RCTExecuteOnMainQueue_block_invoke
_dispatch_call_block_and_release
_dispatch_client_callout
_dispatch_main_queue_callback_4CF
__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
__CFRunLoopRun
CFRunLoopRunSpecific
GSEventRunModal
-[UIApplication _run]
UIApplicationMain
main
start

Reproducible Demo

This is a minimal case that we can verify this crash happening. A simple app to navigate to the 5th (last) page and press the text to remove it. iOS should crash.

import React, {useState} from 'react';
import {Text, View} from 'react-native';
import PagerView from 'react-native-pager-view';

const App = () => {
  const [pages, setPages] = useState(5);

  return (
    <PagerView style={{flex: 1}} initialPage={0}>
      {new Array(pages).fill().map((_, i) => (
        <View
          key={i}
          style={{width: '100%', height: '100%', justifyContent: 'center', alignItems: 'center'}}>
          {i !== pages - 1 ? (
            <Text>Please navigate to next page -></Text>
          ) : (
            <Text
              onPress={() => {
                setPages(pages - 1);
              }}>
              Press me to remove this page
            </Text>
          )}
        </View>
      ))}
    </PagerView>
  );
};
@duailibe duailibe changed the title Removing last page when it's active causes a crash in iOS on RN 0.65.1 Removing last page when it's active causes a crash in iOS on RN 0.64 Oct 22, 2021
@troZee
Copy link
Member

troZee commented Oct 29, 2021

@svenlombaert
Copy link

@troZee This still seems to happen for me on iOS, attached a video. I'm using react-native-tab-view and am going from three tabs to one, and it crashes.

Screen.Recording.2021-11-03.at.10.50.53.mov

If I can do anything to help out, do let me know.

@troZee
Copy link
Member

troZee commented Nov 3, 2021

Due to fact, that above fix did not work, I have reopened the PR #467

@troZee
Copy link
Member

troZee commented Nov 9, 2021

https://github.com/callstack/react-native-pager-view/releases/tag/v5.4.9

@raymishtech
Copy link

@troZee Tried the latest release as well, the fix is not solving the iOS crash issue.

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