[Bug] Power Apps Android app: binary data between a code app and the host breaks — Dataverse image upload fails ("o.arrayBuffer is not a function"), picked files can't be read (FileReader {"code":2}), downloaded images render gray / truncated
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- databases, react, typescript, vite
- Lĩnh vực
- backend-api-design, databases, mobile
Hướng nghiên cứu
Start by tracing the generated service methods uploadFileToRecord, downloadImageFromRecord, and downloadFileFromRecord in the repository; the issue does not name their source files or tests. Compare how they handle binary data in the Android host and browser, then reproduce the upload, picked file read, and image download failures in the Power Apps Android app. Done means standard file APIs and the service methods work with complete image bytes on Android as they do in the browser.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
In the Power Apps Android app, a published code app can't reliably exchange binary data with the host, while the same app works fine in the browser (Edge / Chrome on desktop, apps.powerapps.com/play/...):
- Upload of an image to a Dataverse image column with the generated service (
<Table>Service.upload(id, '<imagecolumn>', file)→uploadFileToRecord) fails witho.arrayBuffer is not a function. - Reading a picked file (
<input type="file" accept="image/*">, the file arrives asresized-<guid>.jpg) withFileReaderfails with an error object that only contains{"code":2}— both right after picking and later.{"code":2}looks like theSECURITY_ERRof a Cordova-styleFileError, not a browserDOMException. - Download of an image with the generated service (
<Table>Service.downloadImage(id, '<imagecolumn>', true)→downloadImageFromRecord) returns data that renders as a gray image with only the top rows of the photo (a truncated / corrupted JPEG). The image stored in Dataverse is complete (verified via the Web API:x-ms-file-size= the uploaded size, the full image opens correctly in the browser version of the same app).
The browser version of the same app (same environment, same records) uploads, reads and shows the images correctly.
Steps to Reproduce
- Create a code app (
@microsoft/power-apps1.5.0,paCLI) with a Dataverse table that has an image column (full image stored:CanStoreFullImage= true) as a data source. - Add an
<input type="file" accept="image/*">; on change, upload the file with the generated service:await <Table>Service.upload(recordId, '<imagecolumn>', file). - Show an image with
await <Table>Service.downloadImage(recordId, '<imagecolumn>', true)→data:URL (blob: URLs are blocked by the CSP) →<img>. - Push the app, open it in the Power Apps Android app (Play Store), pick a photo from the device and upload it; open a record with an image.
Expected behavior
<Table>Service.upload(...)with a pickedFileworks in the Android app as it does in the browser.- A picked file can be read with the standard web APIs (
FileReader,Blob.arrayBuffer()). <Table>Service.downloadImage(...)returns the complete image bytes (aUint8Array), as in the browser.
Actual behavior
| What | Browser | Power Apps Android app |
|---|---|---|
Service.upload(id, column, file) |
works | fails: o.arrayBuffer is not a function |
FileReader.readAsDataURL(file) on the picked file |
works | fails: error object {"code":2} (also right after picking) |
Service.downloadImage(id, column, true) → data: URL |
correct image | gray image, only the top rows visible (corrupted / truncated bytes) |
| Image stored in Dataverse after a browser upload | complete | complete (same record) |
What we tried (in order)
| # | Approach | Result in the Android app |
|---|---|---|
| 1 | <Table>Service.upload(id, column, file) (binary upload via the SDK) |
❌ o.arrayBuffer is not a function |
| 2 | Read the file at save time with FileReader → base64 → save in the record (create with "<imagecolumn>": "<base64>") |
❌ FileReader error {"code":2} |
| 3 | Same, but read the file immediately after picking | ❌ {"code":2} right after picking |
| 4 | Current workaround (works): try every way to get the bytes in turn — file.arrayBuffer(), new Response(file).arrayBuffer(), fetch(URL.createObjectURL(file)), a FileReader taken from a fresh same-origin about:blank iframe, window.FileReader — then re-encode (canvas → JPEG), convert the bytes to base64 without FileReader, and save the image as base64 in the record's create payload ("<imagecolumn>": "<base64>") |
✅ upload works; full image stored (verified via the Web API) |
| 5 | Download: downloadImage(id, column, true); accept every data shape (Uint8Array, ArrayBuffer, number array, base64 / binary string), check the JPEG end marker, fall back to the thumbnail from the query |
❌ still gray: the bytes pass the checks but are corrupted |
Notes:
- Creating records also showed "An unknown error occurred" in the Android app while Dataverse did save the row (the create reads the record back; related: #444). Workaround: set the primary key in the app and check with a list query after an error.
- The host rejected one call with a plain object (shown as
[object Object]), not anError.
Questions for the team
Our workaround (4) works, but it bypasses the SDK's upload and depends on how the Android app exposes picked files. We would prefer the standard approaches to work in the Android app as they do in the browser:
- Can
<Table>Service.upload/uploadFileToRecordaccept a pickedFilein the Android app (the host seems to callarrayBuffer()on an object that doesn't have it)? - Can a file picked in a code app be read with the standard
FileReader/Blob.arrayBuffer()in the Android app? Iswindow.FileReader/Filereplaced inside the code app's frame (the{"code":2}error looks like Cordova'sFileError.SECURITY_ERR)? - Can
<Table>Service.downloadImage(anddownloadFileFromRecord) return the complete binary data in the Android app? It looks like the bytes are converted to text on the way (the JPEG header survives, the rest doesn't). - Is there a recommended way to upload / download images and files from a code app on mobile until this is fixed?
Screenshots or Error Messages
- New record form, Android app:
o.arrayBuffer is not a function(screenshot 1)
- Detail view, Android app: the image renders gray, only the top rows visible; same in the enlarged view (screenshots 2, 3)
The image could not be read: {"code":2}(FileReader on the picked file)
Environment information
- Framework, build tool or relevant package used: React 19, Vite 7, TypeScript 5.9,
@microsoft/power-apps1.5.0,@microsoft/power-apps-vite1.0.2,paCLI 1.3.0 - Any connection/components: Dataverse (native data source, generated services), image column with full image stored; Office 365 Outlook / Users connectors (not involved)
- Device: Android phone, Power Apps app from the Play Store (version: 3.26094.5 ), Android version 16
- Browser comparison: Edge / Chrome on Windows — everything works
Additional context
- The app is pushed with
pa app pushand shipped in a solution; the same behaviour in both. - Related Android issues: #444 (single-record reads hang / fail in the Android app), #364 (100vh on Android).
- Ngôn ngữ chính
- TypeScript
- Star
- 516
- Fork
- 145
- Merge trung bình
- 1 ngày 10 giờ
- Pull request đã merge (30 ngày)
- 23
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của microsoft/PowerAppsCodeApps
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
microsoft/PowerAppsCodeApps#504 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
microsoft/PowerAppsCodeApps#500 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
microsoft/PowerAppsCodeApps#499 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 45/100
microsoft/PowerAppsCodeApps#498 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 22/100
microsoft/PowerAppsCodeApps#472 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của microsoft/PowerAppsCodeApps
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
mobile-next/mobile-mcp#526 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
e2e-failure ready-to-code
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 73/100
redhat-developer/rhdh-plugin-export-overlays#4470 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
anthropics/anthropic-sdk-typescript#1273 ·
Maintainer thường phản hồi trong vòng 10 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
CopilotKit/OpenBot#815 ·
Maintainer thường phản hồi trong vòng 1 ngày