AmazeFileManager icon indicating copy to clipboard operation
AmazeFileManager copied to clipboard

Large file causes Text reader to crash

Open kofuk opened this issue 7 years ago • 10 comments

The app crashed on my Nexus 7(2013), Android 7.12(LineageOS)

How to reproduce

  1. Open large file with Text reader(On my Nexus7(2013), 4042 KB)
  2. Move to home(launcher) or overview screen.
  3. The app crashes! Android said, "data parcel size 2472732 bytes"

Probably, this is related to: https://developer.android.com/about/versions/nougat/android-7.0-changes#other

kofuk avatar Jun 10 '18 00:06 kofuk

In what version of Amaze are you? Can't replicate with an 9 MB file, in master, Pixel 2, Android 8.1.

EmmanuelMess avatar Jun 10 '18 11:06 EmmanuelMess

I used v.3.2.1, latest release. I have the same problem on Nexus 5X, Android 8.0.1. Nexus 7 and 5X has as less as 2GB of memory. This may be the cause of the problem.

kofuk avatar Jun 10 '18 12:06 kofuk

Nexus 7 and 5X has as less as 2GB of memory. This may be the cause of the problem.

I'll reopen for test in a real device.

EmmanuelMess avatar Jun 10 '18 12:06 EmmanuelMess

Sounds like something I faced back in the Gingerbread days...

If you need, try play with the updated TextEditorActivityEspressoTest in TranceLove:AmazeFileManager/verify/issue1275. So far just played with Galaxy Nexus emulator (1GB RAM) running 5.1.1 opening a 4096KB text file, loaded slow but didn't crash. But TextEditorActivity is just running standalone, so YMMV.

TranceLove avatar Jun 17 '18 01:06 TranceLove

I'm getting OutOfMemoryException when loading a 50Mb text file in Nexus 5x running API19. Please note, many famous file managers don't load text files over a certain size (solid explorer has a 2mb limit). I suggest doing the same. In older versions of Amaze we had something like, loading only a limited lines in text editor first, loading more of them as user scrolled. It had it's own obvious downsides so we had to remove that implementation.

VishalNehra avatar Jun 28 '18 08:06 VishalNehra

In older versions of Amaze we had something like, loading only a limited lines in text editor first, loading more of them as user scrolled. It had it's own obvious downsides so we had to remove that implementation.

AFAIK Linux has ways of doing this automatically. My Linux memory managment knowledge tells me that if we read the file from the buffer lazily the memory will not be consumed until the user scroll enough down.

EmmanuelMess avatar Jun 28 '18 12:06 EmmanuelMess

It's possible, but conventional android EditText doesn't support something like this.

On Thu 28 Jun, 2018, 6:14 PM Emmanuel, [email protected] wrote:

In older versions of Amaze we had something like, loading only a limited lines in text editor first, loading more of them as user scrolled. It had it's own obvious downsides so we had to remove that implementation.

AFAIK Linux has ways of doing this automatically. My Linux memory managment knowledge tells me that if we read the file from the buffer lazily the memory will not be consumed until the user scroll enough down.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/TeamAmaze/AmazeFileManager/issues/1275#issuecomment-401021291, or mute the thread https://github.com/notifications/unsubscribe-auth/AE-FsDye_h7j9R5eafRV6MWqrE-SDhUbks5uBM_GgaJpZM4UhhxS .

VishalNehra avatar Jun 28 '18 12:06 VishalNehra

StackOverflow proposes loading into a ListView and dividing the text into pages to be shown in each item.

EmmanuelMess avatar Jun 28 '18 13:06 EmmanuelMess

Is it possible that we use a "sliding window" method to handle big files?

What I have in mind is

  • we open a reference to the input stream, that is the actual file
  • then we only load a portion of the file to the view, e.g. 8KB, or 8MB, depends on requirement
  • when the view reaches the edges of the file portions, pull up/down will load the next portion of the file (like what we will do to update feed in SNS apps)
  • writing contents back just need to write the portion back to the output stream, with skip(). Random access is not necessary, since we should be opening output stream -> skip a number of bytes -> write the content back
  • alternately, we provide path to allow users to navigate to specific location of the file. Just "skip a number of bytes" would be fine, no need to think of hex address as we may do with binary files on desktop

What do you think?

TranceLove avatar May 16 '21 05:05 TranceLove

@TranceLove We had this implementation in previous versions of Amaze. I'll find the apk . We can try to continue from there.

VishalNehra avatar May 16 '21 05:05 VishalNehra