victorsoares96 / epubjs-react-native

ePub.js Reader for React Native
MIT License
142 stars 48 forks source link

Opening multiple books causes resource management problems. #291

Closed aly-001 closed 1 month ago

aly-001 commented 1 month ago

Summary

Hey! So I'm building an Expo application that uses epubjs-react-native.

If I open more than, say 4 different epub files from my device, I get "Opening..." until I reboot my device. I'm pretty sure the issue is due to no method for destroying instances of old readers, and they accumulate up, using the devices resources.

Is there any way to get around this? Like any way to get a reference to the rendition and clean it up/destroy it?

What platform(s) does this occur on?

iOS

What workflow(s) does this occur on?

Expo Workflow

Environment (or package.json)

{ "name": "screens", "version": "1.0.0", "main": "expo/AppEntry.js", "scripts": { "start": "expo start", "android": "expo start --android", "ios": "expo start --ios", "web": "expo start --web" }, "dependencies": { "@epubjs-react-native/core": "^1.4.5", "@epubjs-react-native/expo-file-system": "^1.1.3", "@epubjs-react-native/file-system": "^1.1.3", "@expo-google-fonts/lora": "^0.2.3", "@expo/vector-icons": "^14.0.2", "@microsoft/fetch-event-source": "^2.0.1", "@react-native-async-storage/async-storage": "^1.23.1", "@react-native-community/hooks": "^3.0.0", "@react-navigation/bottom-tabs": "^6.5.20", "@react-navigation/native": "^6.1.17", "@react-navigation/stack": "^6.3.29", "@types/react": "~18.2.79", "axios": "^1.7.2", "eventsource": "^2.0.2", "expo": "~51.0.14", "expo-av": "~14.0.6", "expo-document-picker": "~12.0.2", "expo-file-system": "~17.0.1", "expo-font": "~12.0.7", "expo-image-manipulator": "^12.0.5", "expo-linear-gradient": "^13.0.2", "expo-sqlite": "~14.0.4", "expo-status-bar": "~1.12.1", "express": "^4.19.2", "openai": "^4.52.0", "openai-api": "^1.3.1", "react": "18.2.0", "react-native": "0.74.2", "react-native-fs": "^2.20.0", "react-native-gesture-handler": "^2.17.1", "react-native-paper": "^5.12.3", "react-native-safe-area-context": "^4.10.5", "react-native-screens": "^3.32.0", "react-native-svg": "^15.3.0", "react-native-webview": "^13.10.3", "react-navigation": "^5.0.0", "typescript": "~5.3.3", "ws": "^8.17.1" }, "devDependencies": { "@babel/core": "^7.20.0" }, "private": true }

Your .epub file

No response

Minimal reproducible example

No response

I confirm that i have

aly-001 commented 1 month ago

Never mind, it was caused by the javascript I was injecting running in the background even after the instance of the book was closed.