GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Buffer.prototype.slice does not work on iOS 10 · Issue #136 · feross/buffer

Buffer.prototype.slice does not work on iOS 10 #136

New issue
Copy link
New issue
Copy link
Closed
Closed
Buffer.prototype.slice does not work on iOS 10#136
Copy link

Description

@jonasschnelli
jonasschnelli
opened on Sep 16, 2016
Issue body actions

I tracked down an issue on cordova (includes node.js) where Buffer.prototype.slice result in returning the same value as the input buffer.

In iOS <10, this results shifting out 16 bytes:

var out = this.cache.slice(0, 16)
this.cache = this.cache.slice(16)

In iOS 10, this.cache will be unmodified.

I haven't tracked it down, but seems to be a Buffer.TYPED_ARRAY_SUPPORT problem.
If I remove the if at

buffer/index.js

Line 1078 in c5267f4

if (Buffer.TYPED_ARRAY_SUPPORT) {
it does work on iOS 10.

Activity

  1. feross commented on Sep 16, 2016

    @feross
    feross
    on Sep 16, 2016
    Owner
    More actions

    @jonasschnelli Can you share the version of feross/buffer that you're using? npm ls buffer should help 👍

  2. feross commented on Sep 16, 2016

    @feross
    feross
    on Sep 16, 2016
    Owner
    More actions

    This is due to ES6 support improving in Safari. This issue was fixed a while ago.

    It looks like you're not using the latest version of buffer. Please update browserify to v13.x. If you're already on v13.x, then reinstall it to ensure that the latest version of buffer is being used.

    Cheers!

  3. feross
    closed this as completedon Sep 16, 2016
  4. jonasschnelli commented on Sep 16, 2016

    @jonasschnelli
    jonasschnelli
    on Sep 16, 2016
    Author
    More actions

    Thanks. I'll try to bump to the latest version,

  5. psionic81 commented on Sep 19, 2016

    @psionic81
    psionic81
    on Sep 19, 2016
    More actions

    var arr = Uint8Array.from([1, 2, 3, 4])
    arr.subarray(0, 2).byteLength

    is returning "2" on every other platform, and "1" on ios10

    traced it to the function:

    Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
    ? global.TYPED_ARRAY_SUPPORT
    : typedArraySupport()
    function typedArraySupport () {
    try {
    var arr = new Uint8Array(1)
    arr.foo = function () {
    return 42
    }
    return arr.foo() === 42 && // typed array instances can be augmented
    typeof arr.subarray === 'function' && // chrome 9-10 lack subarray
    arr.subarray(1, 1).byteLength === 0 // ie10 has broken subarray
    } catch (e) {
    return false
    }
    }

  6. feross commented on Sep 19, 2016

    @feross
    feross
    on Sep 19, 2016
    Owner
    More actions

    @psionic81 That code returns 2 for me.

    var arr = Uint8Array.from([1, 2, 3, 4])
    alert(arr.subarray(0, 2).byteLength) // 2
  7. psionic81 commented on Sep 19, 2016

    @psionic81
    psionic81
    on Sep 19, 2016
    More actions

    yep your suggested fix worked fine, thanks for posting it took so long to track this down to the library that had the dependancy that was the issue.. thanks for making your standards completely unstandard apple lol

  8. lamaslam commented on Sep 29, 2016

    @lamaslam
    lamaslam
    on Sep 29, 2016
    More actions

    I have updated Buffer to 5.0.0, Browserify to 13.1.0, still has that problem.

    it craps on Buffer.prototype.slice function

        newBuf = Buffer._augment(this.subarray(start, end))
    

    that subarray return same buffer. it is problem of iOS 10 ?


    I fix this by using

        npm ls buffer 
    

    to get all module using 'buffer'. and remove those version older than 4.9.0, or modify the package.json to using latest and reinstall.

    Of-course you should 'npm install buffer --save' first

  9. feross commented on Sep 29, 2016

    @feross
    feross
    on Sep 29, 2016
    Owner
    More actions

    @lamaslam Where did you find that call to Buffer._augment? That was removed in buffer v4. If you see that in your code, then you're using buffer v3 or older somewhere, so it's not surprising that you're still experiencing this bug.

    Also, you don't need to explicitly install or depend on this buffer package. Just install browserify v13 and you'll be fine. Double check that you're using the right copy of browserify -- you can install it globally and locally. You might have different versions in each of those locations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.