react-fullscreen-crossbrowser icon indicating copy to clipboard operation
react-fullscreen-crossbrowser copied to clipboard

"requestFullscreen is not a function" in safari iOS

Open pmourelle opened this issue 6 years ago • 12 comments

Trying to get fullscreen display goes white and UI blocked, so there's no way to restore it but reloading page.

pmourelle avatar Apr 28 '18 19:04 pmourelle

Hello mate, can you please describe your enivorment?

did you use typescript or javascript? any sample use so I can reproduce? thanks

vasilevich avatar Apr 28 '18 20:04 vasilevich

Sure, I'm using JS on react@16. I'm having something like this:

        <Fullscreen
          className={ classes.FullscreenWrapper }
          enabled={this.state.zoom}
          onChange={zoom => this.setState({zoom})}
        >
          <div className={ classes.FreeHandBox }>
            <SignaturePad
              options={{ penColor: 'blue' }}
              redrawOnResize={true}
              ref={localRef => this.canvas = localRef}
            />

            <Button
              bsSize="small"
              onClick={ () => this.clearCanvas() }
              className={ classes.FreeHandCleanCanvas }>
              <Glyphicon glyph="repeat" />
            </Button>

            <Button
              bsSize="small"
              onClick={ () => this.toggleZoom() }
              className={ classes.FreeHandZoomCanvas }>
              <Glyphicon glyph="fullscreen" />
            </Button>
          </div>
        </Fullscreen>

What I'm doing is using react-screen-orientation to be able to go fullscreen when phone is set in landscape. So signature pad gets full screen with 2 simple UI buttons. This works fine in Chrome and Firefox, but for Safari iOS seems to not be able to recognize the requestFullscreen call, and ends with browser completely white (like a broken fullscreen(?) ). I peeked on your code and prefix seems to be all set good. I'm still debugging it, but if you come across something here please do tell :). Thanks!

PS: what about adding a prop for custom class name? (As the className prop above gets overwritten by component.)

pmourelle avatar Apr 28 '18 23:04 pmourelle

Hi, this might help you debug, does the example in this url work for you? http://fscreen.rafrex.com/

or same result?

vasilevich avatar Apr 28 '18 23:04 vasilevich

image

Damn. So this is some standard Safari thing?

pmourelle avatar Apr 28 '18 23:04 pmourelle

well I am not sure, seems that way, but maybe there is a specific way to do this in safari? maybe the web browser just can't do it

vasilevich avatar Apr 28 '18 23:04 vasilevich

As I've looked around is a known issue around iOS' Safari not supporting fullscreenAPI. "Solution" so far for me is to disable feature for mobile Safari. Total bummer.

Still this issue exists as it tries to use it and breaks with that message above.

pmourelle avatar Apr 29 '18 00:04 pmourelle

well if you have a suggestion how to prevent it from running on the problematic platform please make a pull request and I will update the module shortly.

vasilevich avatar Apr 29 '18 00:04 vasilevich

@vasilevich this is the error: https://github.com/vasilevich/react-fullscreen-crossbrowser/blob/master/src/index.tsx#L113 The enabled is been missconfused with the element I assume, being undefined when fullscreenAPI support is missing, and null when it do has support but there's no element on fullscreen. So I guess you should use fullscreenEnabled() value there, and if that value is true then go on, if not maybe a console.log() letting dev know the lack of support in the browser being tested.

I'm currently busy and don't have time to code/test/PR it now, but I think fixing so ^ should be enough.

pmourelle avatar Apr 29 '18 00:04 pmourelle

Hi friend, I will gladly add what you asked but I am sorry I have no way of testing it, I don't have any IOS devices available. I will add what you asked as soon as possible and let you know if you want. what if I simpley add try{ ... } catch to that block and in the catch enter the console log you mentioned? seems like the easiest way?

vasilevich avatar Apr 29 '18 01:04 vasilevich

I'll be happy to test it when you have it on a branch.

pmourelle avatar Apr 29 '18 02:04 pmourelle

Sorry for posting after many years. I thought this would be very useful for those that crashed into ios/safari issues: https://developer.apple.com/documentation/webkitjs/htmlvideoelement/1633500-webkitenterfullscreen

pleytonsoftware avatar Apr 07 '22 15:04 pleytonsoftware

@pleytonsoftware how did you solve this for using this react-fullscreen-crossbrowser package? did you override the fullscreen onclick functionality to use webkitenterfullscreen() instead, or remove this package and implement your own solution?

annarhughes avatar Sep 13 '22 12:09 annarhughes