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

FileReader.onloadend event of the plugin Cordova-plugin-file is not getting triggered for Android device #544

Open
1 of 3 tasks
KoushikMahadikar opened this issue Nov 15, 2022 · 3 comments
Labels
Requires Triage Tickets that appear to have all the required information but needs to be confirmed for validity

Comments

@KoushikMahadikar
Copy link

Bug Report

Problem

FileReader.onloadend event of the plugin Cordova-plugin-file is not getting triggered for Android device

What is expected to happen?

FileReader.onloadend event of the plugin cordova-plugin-file should be triggered for Android device

What does actually happen?

We are using Cordova plugin cordova-plugin-file to read a file in one of the mobile app. But, FileReader.onloadend event of this plugin is not getting triggered for Android. This issue is replicable in Android 10

Information

We are using Cordova plugin -cordova-plugin-file to read a file in one of the mobile app. But, FileReader.onloadend event of this plugin is not getting triggered for Android. This issue is replicable in Android 10

Command or Code

const reader = new FileReader();
reader.onloadend = (evt: any) => {
imgBlob = new Blob([evt.target.result], { type: 'image/jpeg' });
resolve(imgBlob);
};

Environment, Platform, Device

We are experiencing this issue in Android device which is having Android 10

Version information

cordova-plugin-file version - 6.0.2
cordova-android version - 9.1.0

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above
@breautek breautek added the Requires Triage Tickets that appear to have all the required information but needs to be confirmed for validity label Nov 17, 2022
@mattdsteele
Copy link

I'm seeing similar issues for some Cordova projects. It occurs for me with [email protected], and [email protected]. I'll update with any additional context if I can find it.

@mattdsteele
Copy link

@KoushikMahadikar are you working in an Angular project?

We discovered a similar issue in Capacitor's file loader. It appears to be a bug in zone.js that causes the onloadend method not to make it into the FileReader class. ionic-team/capacitor#1564

This workaround worked for me:

export function getFileReader(): FileReader {
    const fileReader = new FileReader();
    const zoneOriginalInstance = (fileReader as any)["__zone_symbol__originalInstance"];
    return zoneOriginalInstance || fileReader;
}
...
let newInstance = getFileReader();

@danilobassi8
Copy link

I am having the same issue. Any update on this?
I'm going to try @mattdsteele solution, but it'd be great to avoid writing those lines every time I use the reader.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Requires Triage Tickets that appear to have all the required information but needs to be confirmed for validity
Projects
None yet
Development

No branches or pull requests

4 participants